1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| with open("test.utf.txt", "wt", encoding="utf-8") as file_:
file_.write("""
un été qui m'a couté 500 ...
et c'était 💩
"""
)
with open("test.iso.txt", "wt", encoding="iso8859-1") as file_:
file_.write("""
un été qui m'a couté 500 ...
et c'était
"""
)
try:
with open("test.win.txt", "wt", encoding="windows-1252") as file_:
file_.write("""
un été qui m'a couté 500 ...
et c'était (emojy ne passe pas!)
"""
)
except UnicodeEncodeError as err:
print("Erreur", err)
print() |