简体   繁体   English

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

[英]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.

相关问题 如何使Python 3的Print符合命令提示符的大小? - How can I make Python 3's Print fit the size of the command prompt? 如何通过命令提示符导入python文件? - How can I import a python file through a command prompt? 如何使用 Python 访问命令提示符历史记录 - How can I access command prompt history with Python 如何在命令提示符下将 python 变量传递给进程 - How can I pass a python variable to a process in the command prompt 从C调用python回调时,如何解决“ SystemError:内部例程的空参数”错误 - How can I fix “SystemError: null argument to internal routine” error when python callback in called from C 事件可以执行命令吗? 如果是这样,我怎样才能让我的人这样做? - Can an event execute a command? If so, how can I make my one do so? 如何在命令提示符下使用“ SetText”? - How can I use 'SetText' in command prompt? 如何使Python程序可执行文件,使其自动运行 - How can I make a Python program executable so that it automatically runs 我怎样才能使它只有具有特定角色的成员才能执行命令? - How can I make it so only members with a specific role can execute a command? 如何直接从命令提示符访问我用 Anaconda 安装的 Python? - How can I access Python which I installed with Anaconda directly from command prompt?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM