python打印不換行無空格輸出的方法:
使用print()函數(shù)時(shí),并不希望輸出結(jié)束后自動(dòng)換行,因此,我們可以按照下面的方法來做
print()指定結(jié)束符
print('hello',end='')
print('world')
#result:helloworld
當(dāng)print()函數(shù),指定end參數(shù)為空字符后,print()函數(shù)就不再主動(dòng)添加換行符了。并且,hello和world之間也不存在任何空格。
a='firstline'
b='secondline'
c='thirdline'
print(a,end='\n\n')
print(b)
print(c,end='!')
以上內(nèi)容為大家介紹了python如何打印不換行無空格輸出,希望對(duì)大家有所幫助,如果想要了解更多Python相關(guān)知識(shí),請(qǐng)關(guān)注IT培訓(xùn)機(jī)構(gòu):千鋒教育。