当用户插入非英文字符时,脚本会因错误而停止。
# -*- 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'编解码器无法解码位置0中的字节0xd7:序数不在范围内(128