python中print的不換行即時輸出的快速解決方案,pythonprint

來源:互聯網
上載者:User

python中print的不換行即時輸出的快速解決方案,pythonprint

關於Python2.x和3.x帶來的print不換行的問題:昨天有發過推文,利用end = 定義,解決了橫向的小問題,但是由於螢幕顯示的問題,若字串長度過大,則會引起不便。兩個或多個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 testAll 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 ,

以上這篇python中print的不換行即時輸出的快速解決方案就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支援幫客之家。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.