Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
打印没有换行符或空格的变量 python3 通过 print (x,end='') 如何在 python 2.5 中执行
sys.stdout.write除非指定,否则(仅)写入不带换行符的字符串。
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,
注意最后的逗号。