【说站】python删除str中特定字符的方法

python删除str中特定字符的方法

1、删除字符串首尾的多余字符串strip()
# 删除字符串中多余字符
def string_remove():
str1 = ' abc \n'
print str1.strip() # abc
str2 = '----abcdf++++'
print str2.strip('-+') # abcdf
2、replace函数,删除字符串中某一个所有的字符串
ss = 'old old string'