import re
str = 'dsf"safd"sfas\'fwe\'rrw\'erw\'ewwew"rsdr"sdsd'
print(str)
# 将成对的英文双引号改为成对的中文双引号
pattern = re.compile(r'"(.*?)"')
result = pattern.findall(str)
for l in result:
str = str.replace('"{}"'.format(l), '“{}”'.format(l))
# 将成对的英文单引号改为成对的中文单引号
pattern = re.compile(r"'(.*?)'")
result = pattern.findall(str)
for l in result:
str = str.replace("'{}'".format(l), "‘{}’".format(l))
# 将单独的单双引号替换为空
str = str.replace("'", "")
str = str.replace('"', "")
print(str)