当前位置: Python基础教程 > 03-流程控制 > 阅读正文

python的print不换行

2021.6.11.   584 次   193字

python的print函数, 默认是输出内容, 并换行

这里, 我们可以给它指定 end 参数, 让它可以指定字符, 不再是默认的\n换行

print实例

print("hello1")
print("hello2",end=",")
print("hello3")

打印的结果如下:

hello1
hello2,hello3

这是因为, 我们指定了在输出hello2之后, 附带的逗号”,” 如果没指定默认是\n表示换行

本篇完,还有疑问?

加入QQ交流群:11500065636 IT 技术交流群