python除空格和换行符

xiaoxiao2021-02-28  20

strip方法去空格 replace方法既可以去空格也可以去换行(\n)

" xyz ".strip() # returns "xyz" " xyz ".lstrip() # returns "xyz " " xyz ".rstrip() # returns " xyz" " x y z ".replace(' ', '') # returns "xyz"
转载请注明原文地址: https://www.6miu.com/read-450085.html

最新回复(0)