[Python] encoding issue. Replace special character

Discussão em 'Python' iniciado por Stack, Junho 29, 2025.

  1. Stack

    Stack Membro Participativo

    I have a dictionary that looks like this:

    { u'Samstag & Sonntag': u'Ganztags ge\xf6ffnet', u'Freitag': u'18:00 & 22:00'}


    Now I'm trying to replace the \xf6 with ö , but trying .replace('\xf6', 'ö') returns an error:


    UnicodeDecodeError: 'ascii' codec can't decode byte 0xf6 in position 0: ordinal not in range(128)
    ​

    How can I fix this?

    Continue reading...

Compartilhe esta Página