#第一种,只去除两边的引号,保留中间字符的引号
def my_strip(str, char):
if str[0] == char:str = str[1:]
if str[-1] == char:str = str[:-1]
return str
st1 = '"aaa bbb,"ccc""'
st_rm1 = my_strip(st1, '"')
print(st_rm1)
#结果:aaa bbb,"ccc"
#第二种,去除所有的引号
import re
st2 = st = '"aaa bbb,"ccc""'
st_rm2 = re.sub('"', '',st2)
print(st_rm2)
#结果:aaa bbb,ccc
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/17685.html