【发布时间】:2016-01-24 07:48:54
【问题描述】:
如何在 Python 2.7 中拥有与以下相同的功能。请不要有未来。
print(item, end="")
【问题讨论】:
标签: python python-2.7 python-3.x
如何在 Python 2.7 中拥有与以下相同的功能。请不要有未来。
print(item, end="")
【问题讨论】:
标签: python python-2.7 python-3.x
这对你有用吗?
import sys
sys.stdout.write(item)
【讨论】:
在美妙的end=(和sep=)出现在Python 3之前,我曾经在字符串中建立行并一键打印出字符串:
str = "Three integers:"
for iii in range (3):
str = "%s %d" % (str, iii)
print s
不用说,我不再使用 Python 2 编写代码了 :-)
【讨论】: