Debugging is a very important debugging skill in coding. By setting breakpoints during the running process, it helps developers better understand the running process.
Python debugging method:Use the pdb module.
import pdb;pdb.set_trace()
Instructions:
Insert method pdb.set_trace() where breakpoints need to be set.
def apple_task_list():
method = request.method.lower()
import pdb;pdb.set_trace()
if method == 'get':
return _apple_task_list()
elif method == 'post':
# 创建源代码写到单独的文件中
input the command:
After entering the debugging state, you can enter commands to debug
a:(arguments)打印当前函数的参数列表
b:(break)设置断点
c:(continue)继续执行
l:(list)查看当前行的代码段
n:(next)继续执行直到当前函数的下一行或者函数返回值
q:(quit)终止并退出
r:(return)执行代码直到从当前函数返回
s:(step)进入函数,如果在函数调用处执行,则会进入函数体内部
w:(words)显示当前行的上下文信息
pp(变量名):打印变量的值
print(变量名):打印变量的值
help:帮助