来自
help(print):
Help on built-in function print in module builtins:print(...) print(value, ..., sep=' ', end='n', file=sys.stdout) Prints the values to a stream, or to sys.stdout by default. Optional keyword arguments: file: a file-like object (stream); defaults to the current sys.stdout. sep: string inserted between values, default a space. end: string appended after the last value, default a newline.
您可以使用
end关键字:
>>> for i in range(1, 11):... print(i, end='')... 12345678910>>>
请注意,您必须自己进入
print()最后的换行符。顺便说一句,在Python 2中,您将不会获得带有后缀逗号的“ 12345678910”,
1 2 34 5 6 7 8 9 10而是得到了。



