[英]How can I make it so that python can check a SystemError in the command prompt
Each time I run the code it always thinks there is a system error even though there might not be每次我运行代码时,它总是认为存在系统错误,即使可能没有
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)
You can surround the code with a try block:您可以用 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
Have a look at online tutorials or the documentation for more informations查看在线教程或文档以获取更多信息
That being said, it is not a good sign that this error is raised and there is probably a reason for it that should be taken care of.话虽如此,引发此错误并不是一个好兆头,并且可能有一个应该注意的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.