开始使用Python调试器,pdb [关闭]

问题描述 投票:77回答:2

我想将pdb(Python调试器)添加到我的工具箱中。什么是最好的入门方式?

python pdb
2个回答
116
投票

以下是开始使用Python调试器的资源列表:

  1. 阅读Steve Ferb的文章"Debugging in Python"
  2. 观看Eric Holscher的截屏"Using pdb, the Python Debugger"
  3. 阅读Python documentation for pdb — The Python Debugger
  4. 阅读第9章 - 当你甚至不知道要记录什么时:使用调试器 - 来自Karen Tracey的Django 1.1 Testing and Debugging

15
投票

概要:

# epdb1.py -- experiment with the Python debugger, pdb
import pdb
a = "aaa"
pdb.set_trace()
b = "bbb"
c = "ccc"
final = a + b + c
print final

现在运行你的脚本:

$ python epdb1.py
(Pdb) p a
'aaa'
(Pdb)
© www.soinside.com 2019 - 2024. All rights reserved.