【发布时间】:2010-10-02 17:32:52
【问题描述】:
打印一个没有换行符或空格的变量 python3 通过 print (x,end='') 如何在 python 2.5 中做到这一点
【问题讨论】:
标签: python printing formatting python-2.x python-2.5
打印一个没有换行符或空格的变量 python3 通过 print (x,end='') 如何在 python 2.5 中做到这一点
【问题讨论】:
标签: python printing formatting python-2.x python-2.5
sys.stdout.write(仅)写入不带换行符的字符串,除非指定。
>>> x = 4
>>> print x
4
>>> import sys
>>> sys.stdout.write(str(x)) # you have to str() your variables
4>>> # <- no newline
【讨论】:
简单:
print x,
注意最后的逗号。
【讨论】: