繁体   English   中英

如何使 python 可以在命令提示符中检查 SystemError

[英]How can I make it so that python can check a SystemError in the command prompt

每次我运行代码时,它总是认为存在系统错误,即使可能没有

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)

您可以用 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

查看在线教程文档以获取更多信息

话虽如此,引发此错误并不是一个好兆头,并且可能有一个应该注意的原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM