发布时间:2022-07-25 09:42:21 人气:117 作者:多测师
python打印不换行无空格输出的方法:
使用print()函数时,并不希望输出结束后自动换行,因此,我们可以按照下面的方法来做
print()指定结束符
print('hello',end='')
print('world')
#result:helloworld
当print()函数,指定end参数为空字符后,print()函数就不再主动添加换行符了。并且,hello和world之间也不存在任何空格。
a = 'first line'
b = 'second line'
c = 'third line'
print(a,end='\n\n')
print(b)
print(c,end='!')
以上内容为大家介绍了python如何打印不换行无空格输出,希望对大家有所帮助,如果想要了解更多Python相关知识,请关注多测师。https://www.e70w.com/xwzx/