输出没有换行 [英] Output without new line
本文介绍了输出没有换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在不带换行符的情况下将文本输出到控制台? 例如:
how can I output text to the console without new line at the end? for example:
print 'temp1'
print 'temp2'
输出:
temp1
temp2
我需要:
temp1temp2
推荐答案
在最后一个参数后添加逗号:
Add a comma after the last argument:
print 'temp1',
print 'temp2'
或者,致电sys.stdout.write
:
import sys
sys.stdout.write("Some output")
这篇关于输出没有换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文