在这个:https://blog.csdn.net/baidu_19473529/article/details/54949453
里的方法:
s = '\xe9\x9d\x92\xe8\x9b\x99\xe7\x8e\x8b\xe5\xad\x90'ss = s.encode('raw_unicode_escape')print(ss) # 结果:b'\xe9\x9d\x92\xe8\x9b\x99\xe7\x8e\x8b\xe5\xad\x90'sss = ss.decode()print(sss)
如果是中文混合这种乱码,则用循环删除掉
mys='宝石 \x9e\x9d\x99'sl = list(mys)
i=0
while i<len(sl):s=sl[i]try:s=s.encode('raw_unicode_escape').decode('utf-8')i+=1except:#删掉它 sl.remove(s)
mys=''.join(mys)
print(mys)