有没有办法在Python中使用断点?

发布于 2024-09-16 09:10:11 字数 94 浏览 1 评论 0原文

我只是想知道是否有一种方法可以在 IDLE 中添加断点,以便我可以在脚本中的某个点停止并在空闲 shell 中编写其他行进行测试。如果不行的话还有其他软件可以实现这个功能吗?

I am just wondering if there is a way to add breakpoints in IDLE so that I can stop at a point in my script and write other lines in the idle shell for testing. If not, is there other software that can do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

猫弦 2024-09-23 09:10:11

添加该行

import pdb; pdb.set_trace()

您可以在代码中的任何位置 ,到达后它会将您带入调试 shell。非常有用,我有一个 emacs 快捷方式来添加代码片段。

您可能还想查看ipdb,并

import ipdb; ipdb.set_trace()

使用

you can add the line

import pdb; pdb.set_trace()

anywhere in your code, when reached it will drop you into a debug shell. so useful i have an emacs shortcut to add the snippet.

you may also want to look at ipdb, and use

import ipdb; ipdb.set_trace()

instead

夜雨飘雪 2024-09-23 09:10:11

如果您运行的是 Windows,并且想要一个具有更多功能的开发环境,则可以查看 PyScripter比 IDLE 的功能。

If you are running Windows, you might look at PyScripter if you want a development environment with more features than IDLE.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文