码迷,mamicode.com
首页 > 编程语言 > 详细

python3----splitlines

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

标签:表示   blog   world   yourself   class   tin   换行   bsp   pytho   

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

标签:表示   blog   world   yourself   class   tin   换行   bsp   pytho   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!