Python UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 ordinal not in range(128)

前端 未结 3 522
轻奢々
轻奢々 2020-12-31 10:07

I\'m trying to write my first app in Google App Engine with Python (link of the app: http://contractpy.appspot.com/ - it\'s just an experimental app). The entire code is bel

3条回答
  •  执念已碎
    2020-12-31 10:38

    Here you got solution.

    >>> "t".decode("utf-8")
    u't'
    >>> "\x81".decode("utf-8")
    Traceback (most recent call last):
      File "", line 1, in 
      File "encodings/utf_8.py", line 7799, in decode
    UnicodeDecodeError: 'utf8' codec can't decode byte 0x81 in position 0: unexpected code byte
    
    >>> "a\x81b".decode("utf-8", "replace")  # this will decode better and the right way.
    u'a\ufffdb'
    

提交回复
热议问题