首页 > 编程语言 > 详细

python3----splitlines

时间:2018-01-11 22:00:59      阅读:203      评论:0      收藏:0      [点我收藏+]

Python中的splitlines用来分割行。当传入的参数为True时,表示保留换行符 \n。通过下面的例子就很明白了:

 1 mulLine = """Hello!!!
 2  Wellcome to Python‘s world!
 3     There are a lot of interesting things!
 4         Enjoy yourself. Thank you!"""
 5 
 6 print(‘‘.join(mulLine.splitlines()))
 7 print(------------)
 8 print(‘‘.join(mulLine.splitlines(True)))
 9 
10 results:
11 
12 Hello!!! Wellcome to Pythons world!    There are a lot of interesting things!        Enjoy yourself. Thank you!
13 ------------
14 Hello!!!
15  Wellcome to Pythons world!
16     There are a lot of interesting things!
17         Enjoy yourself. Thank you!

 

python3----splitlines

原文:https://www.cnblogs.com/jonm/p/8270284.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!