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

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

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

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

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

猜你喜欢

转载自www.cnblogs.com/thebear/p/9260676.html