第一種:
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代碼換行就是每行后面加個 /
舉個栗子:
time = "2017" print "one" + "," / + "two" / + ",three" + / "," + time
打印出來就是:
one,two,three,2017
再舉一個栗子:
print "this line is toooooooooooo / long"
打印出來:
this line is toooooooooooo long
總結
以上所述是小編給大家介紹的Python 字符串換行的多種方式,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林站長站網站的支持!
新聞熱點
疑難解答