最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python 字符串換行的多種方式

 更新時(shí)間:2018年09月06日 10:03:58   作者:寒爵  
本文通過四種方法給大家介紹了Python 字符串換行的方式,在文中最下面通過代碼給大家介紹了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代碼過長的換行

python代碼換行就是每行后面加個(gè) \

舉個(gè)栗子:

time = "2017"
 print "one" + "," \
 + "two" \
 + ",three" + \
 "," + time

打印出來就是:

one,two,three,2017

再舉一個(gè)栗子:

print "this line is toooooooooooo \
 long"

打印出來:

this line is toooooooooooo long

總結(jié)

以上所述是小編給大家介紹的Python 字符串換行的多種方式,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

  • Python實(shí)現(xiàn)讀取Linux系統(tǒng)的CPU以及內(nèi)存占用

    Python實(shí)現(xiàn)讀取Linux系統(tǒng)的CPU以及內(nèi)存占用

    這篇文章主要為大家詳細(xì)介紹了如何利用Python語言實(shí)現(xiàn)Linux系統(tǒng)的CPU以及內(nèi)存占用,文中的示例代碼講解詳細(xì),具有一定的學(xué)習(xí)價(jià)值,需要的可以收藏一下
    2023-05-05
  • python使用心得之獲得github代碼庫列表

    python使用心得之獲得github代碼庫列表

    最近接了個(gè)項(xiàng)目,要求獲得github的repo的api,度娘了一下,有不少文章介紹,總結(jié)了本文,分享給大家并附上代碼
    2014-06-06
  • 詳解python-docx處理Word必備工具

    詳解python-docx處理Word必備工具

    這篇文章主要介紹了python-docx處理Word必備工具,我主要講講自己用到的幾個(gè)內(nèi)容是怎么設(shè)置的,對python-docx處理Word的相關(guān)知識感興趣的朋友一起看看吧
    2021-10-10
  • python如何基于redis實(shí)現(xiàn)ip代理池

    python如何基于redis實(shí)現(xiàn)ip代理池

    這篇文章主要介紹了python如何基于redis實(shí)現(xiàn)ip代理池,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-01-01
  • python 畫圖 圖例自由定義方式

    python 畫圖 圖例自由定義方式

    這篇文章主要介紹了python 畫圖 圖例自由定義方式,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-04-04
  • python定向爬蟲校園論壇帖子信息

    python定向爬蟲校園論壇帖子信息

    這篇文章主要為大家詳細(xì)介紹了Python定向爬蟲校園論壇帖子信息的相關(guān)方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-07-07
  • 微信跳一跳python代碼實(shí)現(xiàn)

    微信跳一跳python代碼實(shí)現(xiàn)

    這篇文章主要為大家詳細(xì)介紹了微信跳一跳python代碼實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-01-01
  • python中模塊導(dǎo)入模式詳解

    python中模塊導(dǎo)入模式詳解

    這篇文章主要為大家介紹了python中模塊導(dǎo)入的模式詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • Python進(jìn)程multiprocessing.Process()的使用解讀

    Python進(jìn)程multiprocessing.Process()的使用解讀

    這篇文章主要介紹了Python進(jìn)程multiprocessing.Process()的使用,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-02-02
  • python自動(dòng)化測試selenium核心技術(shù)三種等待方式詳解

    python自動(dòng)化測試selenium核心技術(shù)三種等待方式詳解

    這篇文章主要為大家介紹了python自動(dòng)化測試selenium的核心技術(shù)三種等待方式示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步早日升職加薪
    2021-11-11

最新評論

平和县| 黔南| 商河县| 东至县| 德钦县| 德兴市| 乐平市| 南京市| 泾阳县| 德阳市| 锡林郭勒盟| 南岸区| 尼勒克县| 巴楚县| 获嘉县| 大英县| 名山县| 长岭县| 蒙城县| 庆元县| 陕西省| 台中县| 定边县| 九江市| 上杭县| 同江市| 丰宁| 尼玛县| 密云县| 平邑县| 镇远县| 白城市| 慈利县| 怀来县| 丹江口市| 木兰县| 巴彦县| 东至县| 荣成市| 商水县| 神木县|