strip()函数---去除字符串首尾字符

#去除空
>>> s = ' 0000a0bc0000'
>>> s.strip()
'0000a0bc0000'

#去除首尾字符'0'
>>> s = '0000a0bc0000'
>>> s.strip('0')
'a0bc'

#去除转义字符
>>> s = '123 '
>>> s.strip()
'123'
 



 


不传入参数默认去除首尾空格

strip()函数只能去除首尾字符,中间的字符并不能去除

原文地址:https://www.cnblogs.com/thebear/p/9260676.html