python3----splitlines

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

 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 Python's world!    There are a lot of interesting things!        Enjoy yourself. Thank you!
13 ------------
14 Hello!!!
15  Wellcome to Python's world!
16     There are a lot of interesting things!
17         Enjoy yourself. Thank you!
原文地址:https://www.cnblogs.com/jonm/p/8270284.html