gpt4 book ai didi

python-3.x - Visual Studio Code Python 调试 "Exception has occurred SystemExit"

转载 作者:行者123 更新时间:2023-12-02 22:30:27 24 4
gpt4 key购买 nike

我长期以来一直使用带有 Python 扩展的 Visual Studio 代码。

目前我有 Visual Studio Code 版本 1.27.2、Python 扩展“ms-python.python”版本 2018.8.0、python 版本 3.6.6,由 Windows 10 1803 企业版系统托管。

与过去相比,最新版本的 Code/MS Python 在调试过程中的表现有所不同。

过去,在 Visual Studio Code 中执行以下 Python 代码不会生成任何异常:

# Import exit from sys
from sys import exit as sys_exit
# Exit to system with errorlevel set to 1
sys_exit(1)
# Next instruction is never executed.
# Executing the script directly from the terminal in Windows sets the
# errorlevel to 1 and the script execution is terminated.
print('unreachable code')

现在,当执行 sys_exit(1) 指令时,结果是 SystemExit 异常 ( VSCode screenshot )。

问题:有没有办法禁用此行为并返回到上一个行为?

最佳答案

我在调试 Flask 应用程序时遇到了类似的情况。我的解决方法是取消选中调试窗口底部的断点菜单中的“未捕获的异常”。

enter image description here

关于python-3.x - Visual Studio Code Python 调试 "Exception has occurred SystemExit",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52372810/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com