python3 随笔记- 去除空格、换行符
一、去除空格
strip()
" xyz ".strip() # returns "xyz"
" xyz ".lstrip() # returns "xyz "
" xyz ".rstrip() # returns " xyz"
" x y z ".replace(' ', '') # returns "xyz"
二、替换 replace("space","")
用replace("\n", ""),后边的串替换掉前边的
三、split 分隔符
x="'a','b'"
x.split(',')
#return ['a','b']
posted on 2017-04-08 13:22 Tolly's_Blog 阅读(615) 评论(0) 收藏 举报
浙公网安备 33010602011771号