import sys
def main():
keystr = input("Enter the Key: ")
key = int(keystr)
if (key <=0) or (key>=25):
print("The key is out of range")
sys.exit()
当我想终止输入密钥(&lt; = 0或&gt; = 25)时,会出现错误消息。
The key is out of rangeTraceback (most recent call last):
File "C:/Users/USER/Desktop/caesarRefactored.py", line 38, in <module>
main()
File "C:/Users/USER/Desktop/caesarRefactored.py", line 11, in <module>
sys.exit()
builtins.SystemExit:
我该如何解决? 错误显示,我正在机翼空闲时运行它。如果在终端上,它可以正常工作。