Skip to main content
 首页 » 编程设计

python之如何在执行开始时通过 PTVS 附加到正在运行的 python 脚本

2025年05月04日33emanlee

我想附加到另一个程序 (.exe) 调用的 python 脚本。

我正在开发 python 脚本。

现在,我正在使用 (Python 2.7)

raw_input("Press Enter to continue and/or attach debugger...") 

让脚本等待并附加调试器。

有没有什么方便的方法,比如C#

Debugger.Break() 

(参见 https://stackoverflow.com/a/105599/586754)直接提示我附加已打开的 Visual Studio 实例?手动附加(尤其是在执行多次运行时)需要一些时间。我经常这样做,我什至知道 Ctrl+Alt+P 可以打开附加对话框(然后单击程序列表,为 python 按 p,单击附加..)。

请您参考如下方法:

目前没有这样的东西。欢迎调用file a feature request .