亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

python中print的不換行即時(shí)輸出的快速解決方法

原創(chuàng) 2017-01-16 17:19:40 619
摘要:關(guān)于Python2.x和3.x帶來的print不換行的問題:昨天有發(fā)過推文,利用end = 定義,解決了橫向的小問題,但是由于屏幕顯示的問題,若字符串長度過大,則會(huì)引起不便。兩個(gè)或多個(gè)print做分割的情況下,如何保持依然橫向輸出,一般的是在print尾部加上逗號(,)但是在3.x下,則不行,需要使用end = "(something)",some signs like , .

關(guān)于Python2.x和3.x帶來的print不換行的問題:昨天有發(fā)過推文,利用end = 定義,解決了橫向的小問題,但是由于屏幕顯示的問題,若字符串長度過大,則會(huì)引起不便。兩個(gè)或多個(gè)print做分割的情況下,如何保持依然橫向輸出,一般的是在print尾部加上逗號(,)但是在3.x下,則不行,需要使用end = "(something)",some signs like , . ; 'also you can put a word or str in"".

Example:

############################################
end1 = "j"
end2 = "u"
end3 = "s"
end4 = "t"
end5 = "t"
end6 = "e"
end7 = "s"
end8 = "t"
print(end1 + end2 + end3 + end4,end = " ")
print(end5 + end6 + end7 + end8)
############################################
Explain:
You can see that i put space between""
There will be something in your screen:
just test
All the codes was run in python 3.2,if you write the codes in pythons 2.x,like python2.7,    
##################################################
end1 = "j"
end2 = "u"
end3 = "s"
end4 = "t"
end5 = "t"
end6 = "e"
end7 = "s"
end8 = "t"
print(end1 + end2 + end3 + end4,)
print(end5 + end6 + end7 + end8)
#################################################
that's all,in python 2.x      
so the differences is:
3.2 end = " "
2.7 ,

更多關(guān)于python中print的不換行即時(shí)輸出的快速解決方法請關(guān)注PHP中文網(wǎng)(ipnx.cn)其他文章! 

發(fā)佈手記

熱門詞條