新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python如何去空格和回車?
python去掉空格和回車的方法:

1、使用strip()、lstrip()、rstrip()等方法刪除字符串中的空格(這些方法只能刪除字符串兩端的空格)
" xyz ".strip() # returns "xyz" " xyz ".lstrip() # returns "xyz " " xyz ".rstrip() # returns " xyz"
2、使用replace()方法將空格替換為空
" x y z ".replace(' ', '') # returns "xyz"
3、使用replace("\n", "")方法將換行符替換為空。
文章題目:創(chuàng)新互聯(lián)Python教程:python如何去空格和回車?
瀏覽地址:http://www.fisionsoft.com.cn/article/dhsiggo.html


咨詢
建站咨詢
