python 转码报错decoding Unicode is not supported

时间:2025-04-07 09:42:56

PythonUnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 937: ordinal not in range(128) Logged from file ,


u = unicode("辣", "utf-8")
unicode(u'foo', 'utf-8')
以上这种转码方式可能会报错,如果报错请使用一下这种,在字符串后面添加 encode("utf-8")


result = (param).encode("utf-8")