This is a list of Integers and this is how they are printing:
[7, 7, 7, 7]
I want them to simply print like this:
7777
I don't want brackets, commas or quotes. What to do?
This is a list of Integers and this is how they are printing:
[7, 7, 7, 7]
I want them to simply print like this:
7777
I don't want brackets, commas or quotes. What to do?
如果您使用的是 Python 3 或适当的 Python 2.x 版本,from __future__ import print_function
则:
data = [7, 7, 7, 7]
print(*data, sep='')
否则,您需要转换为字符串并打印:
print ''.join(map(str, data))
Try this:
print("".join(str(x) for x in This))
.format
从 Python 2.6 及更高版本使用:
>>> print '{}{}{}{}'.format(*[7,7,7,7])
7777
>>> data = [7, 7, 7, 7] * 3
>>> print ('{}'*len(data)).format(*data)
777777777777777777777777
对于 Python 3:
>>> print(('{}'*len(data)).format(*data))
777777777777777777777777
您可以将其转换为字符串,然后转换为 int:
print(int("".join(str(x) for x in [7,7,7,7])))
Something like this should do it:
for element in list_:
sys.stdout.write(str(element))