Python 字符串換行的多種方式
第一種:
x0 = '<?xml version="1.0"?>' \ '<ol>' \ ' <li><a href="/python" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Python</a></li>' \ ' <li><a href="/ruby" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Ruby</a></li>' \ '</ol>'
第二種:
x1 = '<?xml version="1.0"?> \ <ol> \ <li><a href="/python" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Python</a></li> \ <li><a href="/ruby" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Ruby</a></li> \ </ol>'
第三種:
x2 = ('<?xml version="1.0"?>' '<ol>' ' <li><a href="/python" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Python</a></li>' ' <li><a href="/ruby" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Ruby</a></li>' '</ol>')
第四種:
x3 = '''<?xml version="1.0"?> <ol> <li><a href="/python" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Python</a></li> <li><a href="/ruby" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Ruby</a></li> </ol>'''
下面看下python代碼過長(zhǎng)的換行
python代碼換行就是每行后面加個(gè) \
舉個(gè)栗子:
time = "2017" print "one" + "," \ + "two" \ + ",three" + \ "," + time
打印出來(lái)就是:
one,two,three,2017
再舉一個(gè)栗子:
print "this line is toooooooooooo \ long"
打印出來(lái):
this line is toooooooooooo long
總結(jié)
以上所述是小編給大家介紹的Python 字符串換行的多種方式,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
python的pygal模塊繪制反正切函數(shù)圖像方法
在本篇文章中我們給大家整理了關(guān)于如何用python的pygal模塊繪制反正切函數(shù)圖像的知識(shí)點(diǎn)內(nèi)容,有需要的朋友們可以學(xué)習(xí)下。2019-07-07Tensorflow2.10實(shí)現(xiàn)圖像分割任務(wù)示例詳解
這篇文章主要為大家介紹了Tensorflow2.10實(shí)現(xiàn)圖像分割任務(wù)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-01-01python實(shí)現(xiàn)簡(jiǎn)易的學(xué)生信息管理系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)簡(jiǎn)易的學(xué)生信息管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-05-05python Matplotlib畫圖之調(diào)整字體大小的示例
本篇文章主要介紹了python Matplotlib畫圖之調(diào)整字體大小的示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧2017-11-11python 處理telnet返回的More,以及get想要的那個(gè)參數(shù)方法
今天小編就為大家分享一篇python 處理telnet返回的More,以及get想要的那個(gè)參數(shù)方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧2019-02-02Python OpenCV實(shí)現(xiàn)基本圖形繪制
這篇文章主要介紹了Python OpenCV實(shí)現(xiàn)基本圖形繪制,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-04-04Python使用pyautogui模塊實(shí)現(xiàn)自動(dòng)化鼠標(biāo)和鍵盤操作示例
這篇文章主要介紹了Python使用pyautogui模塊實(shí)現(xiàn)自動(dòng)化鼠標(biāo)和鍵盤操作,簡(jiǎn)單描述了pyautogui模塊的功能,并結(jié)合實(shí)例形式較為詳細(xì)的分析了Python使用pyautogui模塊實(shí)現(xiàn)鼠標(biāo)與鍵盤自動(dòng)化操作相關(guān)技巧,需要的朋友可以參考下2018-09-09