你可以这样做: 可以忽略非ASCII字符并编码为ASCII,也可以编码为UTF-8
text = "\u54c8\u54c8\u54c8\u54c8" utf8string = text.encode("utf-8") asciistring1 = text.encode("ascii", 'ignore') asciistring2 = text.encode("ascii", 'replace')
你可以参考 https://www.oreilly.com/library/view/python-cookbook/0596001673/ch03s18.html