如何在 IDLE 中向 Python 程序添加断点?
我已经解决了这个问题,我只是将其发布在这里,因为我无法通过谷歌或阅读文档来解决这个问题。我只是偶然发现的。
要添加断点,右键单击要添加断点的行,然后选择“设置断点”。该行将突出显示。 (请注意,这仅在您编辑文件时有效;它在解释器中不起作用。)
此站点有关于使用 IDLE 调试器的详细教程。
在 Mac 上,您需要按住 Control 键单击而不是右键单击。
I solved this already, I'm just posting it here because I couldn't figure it out with google, or by reading the docs. I only found it by accident.
To add a breakpoint, right-click on the line that you want to add a breakpoint on and select "Set Breakpoint". The line will become highlighted. (Note that this only works when you are editing a file; it does not work at the interpreter.)
This site has a detailed tutorial about using the IDLE debugger.
On Mac, you need to Control-click instead of right clicking.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
完成OP提供的答案:设置断点后 - 您必须打开IDLE Shell的调试模式(使用debug --> debugger)。运行程序时,在打开的调试窗口中按“Go”,IDLE 将在断点处停止。
IDLE Shell 是当您按 F5 运行 Python 脚本时出现的窗口。
Completing the answer supplied by the OP: after setting the breakpoint - you must turn on IDLE Shell's debug mode (using debug --> debugger). When you run the program, press "Go" in the debug window that opens up and IDLE will stop at the breakpoint.
IDLE Shell is the window that appears when you hit F5 to run your Python script.
有一个关于缺少 IDLE 断点文档的开放式 Python 问题。欢迎投稿!
更新:在 Nick 的帮助下,在线文档和 IDLE 帮助文件(针对 2.7.4、3.2.4 和 3.3.0)已更新。
There is an open Python issue about the lack of documentation for IDLE breakpoints. Contributions welcome!
Update: The on-line documentation and the IDLE help files (for 2.7.4, 3.2.4, and 3.3.0) have been updated, with Nick's help.
您可以在运行之前设置断点。
You can set breakpoint before it is run.
只是添加到这个答案(本来会发表评论,但对于规则说我没有足够的声誉来这样做):在Mac上,您必须按住Control键单击。至少对于触控板来说,正常的“右键单击”无法调出带有设置断点选项的上下文菜单。
Just adding to this answer (would've commented but for the rules that say I don't have enough reputation to do so): On the Mac you must control-click. The normal "right-click" at least for the trackpad does not work to bring up the contextual menu with the option to set a breakpoint.