Python调试提示 [英] Python debugging tips
问题描述
请不要只列出一个特定的调试器,而不用说实际可以做什么。
相关
- 什么是使我的Python代码第一次运行的好方法? - 讨论最小化错误
您可以使用pdb模块,在任何地方插入 pdb.set_trace()
,它将用作断点。
>>> import pdb
>>>> a =a string
>>>> pdb.set_trace()
--Return -
> < stdin>(1)< module>() - > None
(Pdb)pa
'a string'
(Pdb)
要继续执行,请使用 c
(或 cont
或 continue
)。
可以使用pdb执行任意的Python表达式。例如,如果发现错误,可以更正代码,然后键入一个类型表达式,以便在运行代码中具有相同的效果。
ipdb是pdb的一个版本 IPython 。它允许使用pdb与所有的IPython功能,包括选项卡完成。
也可以设置pdb自动运行在未捕获的异常。
Pydb 被写为Pdb的增强版本。好处?
What are your best tips for debugging Python?
Please don't just list a particular debugger without saying what it can actually do.
Related
- What are good ways to make my Python code run first time? - This discusses minimizing errors
You can use the pdb module, insert pdb.set_trace()
anywhere and it will function as a breakpoint.
>>> import pdb
>>> a="a string"
>>> pdb.set_trace()
--Return--
> <stdin>(1)<module>()->None
(Pdb) p a
'a string'
(Pdb)
To continue execution use c
(or cont
or continue
).
It is possible to execute arbitrary Python expressions using pdb. For example, if you find a mistake, you can correct the code, then type a type expression to have the same effect in the running code
ipdb is a version of pdb for IPython. It allows the use of pdb with all the IPython features including tab completion.
It is also possible to set pdb to automatically run on an uncaught exception.
Pydb was written to be an enhanced version of Pdb. Benefits?
这篇关于Python调试提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!