[Python] UnicodeDecodeError, invalid continuation byte

Discussão em 'Python' iniciado por Stack, Fevereiro 18, 2025.

  1. Stack

    Stack Membro Participativo

    Why is the below item failing? Why does it succeed with "latin-1" codec?

    o = "a test of \xe9 char" #I want this to remain a string as this is what I am receiving
    v = o.decode("utf-8")


    Which results in:

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
    UnicodeDecodeError: 'utf8' codec can't decode byte 0xe9 in position 10: invalid continuation byte

    Continue reading...

Compartilhe esta Página