Python splitlines使用技巧

2021-08-30 21:02:44 字數 403 閱讀 7475

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'去除。

Python splitlines使用技巧

複製 如下 mulline hello wellcome to python s world there are a lot of interesting things enjoy yourself.thank you print join mulline.splitlines print prin...

UIAlertController使用技巧

由於在ios8之後,蘋果將uialertview和uiactionsheet兩者進行了整合,用uialertcontroller來代替 如何建立uialertcontroller uialertcontroller alertcontroller uialertcontroller alertcon...

perl use vars pragma使用技巧

perl 中的vars是perl中的乙個pragma 預編譯指示符 專門用來預定義全域性變數,這些預定義後的全域性變數在qw 列表中,在整個引用perl檔案中皆可使用,即便使用use strict也不會報錯 複製 如下 use strict str hello world n 報錯資訊 global...