每次运行代码时,它总是认为即使没有可能也会出现系统错误
def Check():
if SystemError:
Label3 = tk.Label(root, text='Error: Invalid Version\nor already installed', bg="lightblue")
Label3.config(font=('Ariel', 12), fg='red')
canvas.create_window(150,330, window=Label3)
else:
success = tk.Label(root, text='Success!', bg="lightblue")
success.config(font=('Ariel', 12), fg='green')
canvas.create_window(150,330, window=success)
答案 0 :(得分:0)
您可以使用try块将代码括起来:
try:
code_that_may_raise_an_error()
# continue here when there was no error
except SystemError:
# handle the error here
else:
# handle the error free case here
在线查看tutorials或documentation以获得更多信息
话虽这么说,这不是引发此错误的好兆头,可能有一个应解决的原因。