python - 在没有空格或换行符的python中打印变量

打印不带换行符或空格的变量
python3打印(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