Python 字符串换行的多种方式
Python  /  管理员 发布于 6年前   137
第一种:
x0 = '<?xml version="1.0"?>' \ '<ol>' \ ' <li><a href="https:python" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Python</a></li>' \ ' <li><a href="https: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="https:python" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Python</a></li> \ <li><a href="https: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="https:python" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Python</a></li>' ' <li><a href="https: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="https:python" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Python</a></li> <li><a href="https: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 字符串换行的多种方式,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对站的支持!
123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..路人 在
php中使用hyperf框架调用讯飞星火大模型实现国内版chatgpt功能示例中评论 教程很详细,如果加个前端chatgpt对话页面就完美了..Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号