#python #python-3.x
#python #python-3.x
Вопрос:
Каждый раз, когда я запускаю код, он всегда думает, что есть системная ошибка, хотя ее может и не быть
def Check():
if SystemError:
Label3 = tk.Label(root, text='Error: Invalid Versionnor 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)
Ответ №1:
Вы можете окружить код блоком 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
Взгляните на онлайн-руководства или на документацию для получения дополнительной информации
При этом, это не очень хороший признак того, что эта ошибка возникает, и, вероятно, для этого есть причина, о которой следует позаботиться.