shenyg 发表于 2017-4-24 07:27:56

Python splitlines使用技巧

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

mulLine = """Hello!!!
Wellcome to Python's world!
There are a lot of interesting things!
Enjoy yourself. Thank you!"""

print ''.join(mulLine.splitlines())
print '------------'
print ''.join(mulLine.splitlines(True))

****************
今天使用这个时候,不清楚splitlines可以将'\n'去除。
页: [1]
查看完整版本: Python splitlines使用技巧