有没有在python中使用断点的方法?

时间:2022-04-02 09:26:46

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?

我只是想知道是否有一种方法可以在IDLE中添加断点,以便我可以在脚本中的某个点停止并在空闲shell中写入其他行进行测试。如果没有,是否有其他软件可以做到这一点?

3 个解决方案

#1


6  

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.

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

you may also want to look at ipdb, and use

您可能还想查看ipdb,并使用

import ipdb; ipdb.set_trace()

instead

代替

#2


3  

http://docs.python.org/library/pdb.html

http://docs.python.org/library/pdb.html

#3


1  

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

如果您运行的是Windows,那么如果您希望开发环境具有比IDLE更多的功能,则可以查看PyScripter。

#1


6  

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.

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

you may also want to look at ipdb, and use

您可能还想查看ipdb,并使用

import ipdb; ipdb.set_trace()

instead

代替

#2


3  

http://docs.python.org/library/pdb.html

http://docs.python.org/library/pdb.html

#3


1  

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

如果您运行的是Windows,那么如果您希望开发环境具有比IDLE更多的功能,则可以查看PyScripter。