python处理解析出的json字符串的中的非法引号
import re
# entity = "xxx,'xx,\"xxx,“xx”,xx"
entity ="迪士尼的\"木兰\"动作片"
print(entity)
# rep = {'\n': '', ' ': '', '<p>': '', '\\': '', '“':'','”':'','"':'', '\'': ''}
repl = {'《': '', '》': '','“':'','”':'','"':'','\'':''}
repl = dict((re.escape(k), v)
for k, v in repl.items())
pattern = re.compile("|".join(repl.keys()))
entity = pattern.sub(
lambda m: repl[re.escape(m.group(0))],entity)
print('entity', entity)
# entity = entity.strp(string.punctuation)