0

When the user inserts non-English characters, the script stops with an error.

# -*- coding: utf-8 -*-
from Tkinter import *
wnd = Tk()
name_A = Entry(wnd)
name_A.pack()
def AAAA1():
     A1 = name_A.get()
     with open("file_name.TXT", 'w') as f:
        f.write(A1)
Button(wnd, text="GO", command=AAAA1).pack()
wnd.mainloop()

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

BenZion
  • 1
  • 2
  • 2
    what is the error message? – pjpj Feb 18 '18 at 09:06
  • Seems to be a bug with Tkinter, you can find more info here: [link](https://stackoverflow.com/questions/34116195/why-some-characters-can-not-be-typed-in-pythons-idle) – neznidalibor Feb 18 '18 at 09:10
  • @BenZion please post the \*full\* traceback into the question body by clicking the edit button. – Taku Feb 18 '18 at 09:19
  • 1
    @BenZion Always update your question, don't hide additional information/code in the comments. You can't format properly here and people tend not to read comments carefully. – Mr. T Feb 18 '18 at 09:20
  • http://farmdev.com/talks/unicode/ –  Feb 18 '18 at 09:22
  • https://stackoverflow.com/questions/6048085/writing-unicode-text-to-a-text-file –  Feb 18 '18 at 09:29

0 Answers0