Polish characters in utf-8 change after being saved to a textfile (Python)

Viewed 19

The character "\xc4\x86" represents letter "Ć". Yet, after executing this code:

string = "ABC\xc4\x86def"

with open("messagessemi.txt","w", encoding = "utf-8") as f:
    f.write(string)

the content of "messagessemi.txt" looks like this:

ABCÄdef

What should I do to save the letters in a correct way? Thank you for any clues.

0 Answers
Related