[英]Decode french accent not working with utf-8
我嘗試解碼這個非常簡單的變量b'autorite nt\\syst\x8ame\r\n'
b'autorite nt\\syst\x8ame\r\n'
>>> t.decode('utf-8')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8a in position 16: invalid start byte
但是沒有任何效果,它應該打印autorite nt\\système
但我找不到正確打印它的方法
它沒有編碼為 UTF-8。 它可能是 cp437,或以下任何一種:cp437、cp720、cp850、cp857、cp858、cp860、cp861、cp863、cp865(來源)
>>> print(b'autorite nt\\syst\x8ame\r\n'.decode('cp437'))
autorite nt\système
您可以將解碼與utf-8
編碼和替換規則一起使用。
t = b'autorite nt\\syst\x8ame\r\n'
t.decode('utf-8', 'replace')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.