簡體   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