打印一个没有换行符或空格的变量 python3 通过 print (x,end='') 如何在 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
https://stackoverflow.com/questions/3846801/