我有下面的绳子-
“\xad\x80\xB1\x93”
使用此字符串在PostgreSQL DB中执行查询时,会引发以下错误-
DataError: invalid byte sequence for encoding "UTF8": 0xed 0xad 0x80在python 2.7中测试它时(在执行查询之前),它不会引发异常-
窗户测试-
'\xed\xad\x80\xed\xb1\x93'.decode("utf-8")
u'\U000e0053'Linux测试-
'\xed\xad\x80\xed\xb1\x93'.decode("utf-8")
u'\udb40\udc53'在python3中,它实际上引发了一个异常-
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xed in position 0: invalid continuation byte我如何在python2.7中签入它不是有效的utf-8字符串?
https://stackoverflow.com/questions/64643547
复制相似问题