python使用print不换行

在默认情况下,print函数输出内容后会自动换行
例如:

print('test')
print('test')

输出为

test
test

如果不希望末尾换行,可以在print函数输出内容的后面增加,end=""
其中""中间可以指定print函数输出内容之后,继续希望显示的内容
例如:

print('test',end="")
print('test')

输出为

testtest

猜你喜欢

转载自blog.csdn.net/u014609263/article/details/90448199