Linux下运行python脚本,pudb是一个不错的调试器。

语法高亮,断点,调用栈,命令行,都有了,如下图。

[安装]

pip install pudb

[使用]

pudb xxx.py

[快捷键]

最常用的快捷键,应该是如下几个:

  • n - step over ("next") # 运行到下一行
  • s - step into # 运行进函数
  • c - continue # 继续运行
  • r/f - finish current function # 结束当前函数
  • b - toggle breakpoint # 打断点/取消断点
  • V - focus variables # 聚焦在变量窗口
  • f1/?/H - show this help screen # 显示帮助窗口
  • Ctrl-n/p - browse command line history # 浏览命令行历史
  • t/r/s/c - show type/repr/str/custom for this variable # 切换type/repr/str/custom

界面下按?就能出来快捷键列表,如下:

Welcome to PuDB, the Python Urwid debugger.
------------------------------------------- (This help screen is scrollable. Hit Page Down to see more.) Keys: # 快捷键相关
Ctrl-p - edit preferences # 编辑配置 n - step over ("next") # 运行到下一行
s - step into # 运行进函数
c - continue # 继续运行
r/f - finish current function # 结束当前函数
t - run to cursor # 运行到光标处
e - show traceback [post-mortem or in exception state] # 显示traceback H - move to current line (bottom of stack) # 移动到当前行(栈底)
u - move up one stack frame # 移动到栈的上一行
d - move down one stack frame # 移动到栈的下一行 o - show console/output screen # 显示命令行屏幕(回车返回pudb) b - toggle breakpoint # 打断点/取消断点
m - open module # 打开python模块 j/k - up/down # 上/下
Ctrl-u/d - page up/down # 上一页/下一页
h/l - scroll left/right # 左滚动/右滚动
g/G - start/end # 跳转到首行/末行
L - show (file/line) location / go to line # 跳到指定行
/ - search # 查找
,/. - search next/previous # 查找下一个/上一个 V - focus variables # 聚焦在变量窗口
S - focus stack # 聚焦在栈窗口
B - focus breakpoint list # 聚焦在断点列表窗口
C - focus code # 聚焦在代码窗口 f1/?/H - show this help screen # 显示帮助窗口
q - quit # 退出 Ctrl-c - when in continue mode, break back to PuDB # 当处于连续模式时,返回pudb Ctrl-l - redraw screen # 重绘窗口 Command line-related: # 命令行相关
! - invoke configured python command line in current environment # 进入命令行窗口
Ctrl-x - toggle inline command line focus # 切换命令行窗口和代码窗口 +/- - grow/shrink inline command line (active in command line history) # 增长/缩减命令行(命令行历史下激活)
_/= - minimize/maximize inline command line (active in command line history)# 最小化/最大化命令行(命令行历史下激活) Ctrl-v - insert newline # 插入新行
Ctrl-n/p - browse command line history # 浏览命令行历史
Tab - yes, there is (simple) tab completion # 快速补齐 Sidebar-related (active in sidebar): # 工具栏相关(工具栏激活时有效)
+/- - grow/shrink sidebar # 扩大/缩减工具栏(指的是工具栏宽度)
_/= - minimize/maximize sidebar # 最小化/最大化工具栏
[/] - grow/shrink relative size of active sidebar box # 扩大/缩减激活工具栏相对大小(指的是窗口高度) Keys in variables list: # 变量列表窗口的快捷键
\ - expand/collapse # 展开/收缩
t/r/s/c - show type/repr/str/custom for this variable # 切换type/repr/str/custom
h - toggle highlighting # 切换高亮
@ - toggle repetition at top # 切换顶部重复
* - cycle attribute visibility: public/_private/__dunder__ # 属性的循环可视化
m - toggle method visibility # 切换方法的可见性
w - toggle line wrapping # 切换换行
n/insert - add new watch expression # 添加新的watch表达式
enter - edit options (also to delete) # 编辑选项 Keys in stack list: # 栈列表窗口的快捷键 enter - jump to frame # 跳到某帧 Keys in breakpoints view: # 断点列表窗口的快捷键 enter - edit breakpoint # 编辑断点
d - delete breakpoint # 删除断点
e - enable/disable breakpoint # 启用/禁用断点

当你不知道如何点中OK键时,试试移动上下左右的箭头键,Enjoy it :)

[笔记]Python的调试器pudb简易教程的更多相关文章

  1. Pdb— Python的调试器

    参考:Pdb- Python的调试器 pdb 模块定义了一个交互式源代码调试器,用于 Python 程序.它支持在源码行间设置(有条件的)断点和单步执行,检视堆栈帧,列出源码列表,以及在任何堆栈帧的上 ...

  2. 用python开发调试器——起始篇

    首先,你得准备一套python开发环境,正常情况下,一般是在windows下开发的,因为win系统应用广泛,再则就是要有个IDE,这里我选择我熟悉的Eclipse.环境搭建,网上都有,比如:http: ...

  3. Visual Studio图形调试器详细使用教程(基于DirectX11)

    前言 对于DirectX程序开发者来说,学会使用Visual Studio Graphics Debugger(图形调试器)可以帮助你全面了解渲染管线绑定的资源和运行状态,从而确认问题所在.现在就以我 ...

  4. RenderDoc图形调试器详细使用教程(基于DirectX11)

    前言 由于最近Visual Studio的图形调试器老是抽风,不得不寻找一个替代品了. 对于图形程序开发者来说,学会使用RenderDoc图形调试器可以帮助你全面了解渲染管线绑定的资源和运行状态,从而 ...

  5. python基础——调试

    python基础——调试 程序能一次写完并正常运行的概率很小,基本不超过1%.总会有各种各样的bug需要修正.有的bug很简单,看看错误信息就知道,有的bug很复杂,我们需要知道出错时,哪些变量的值是 ...

  6. python的调试

    调试 程序能一次写完并正常执行的概率很小.总会有各种各样的bug需要修正. 有的bug很简单,看看错误信息就知道,有的bug很复杂,我们需要知道出错时 哪些变量的值是正确的,哪些变量的值是错误的,因此 ...

  7. python错误调试print、assert、logging、pdb、pdb.set_trace()

    世界人都知道,程序总会有bug存在.复杂点的bug一般人不能一眼看出,这就一要一套调试程序的手段. 方法一:使用print()函数直接打印: >>> def foo(s): ... ...

  8. 《python灰帽子》学习笔记:写一个windos 调试器(一)

    一.开发内容介绍 为了对一个进程进行调试,你首先必须用一些方法把调试器和进程连接起来.所以, 我们的调试器要不然就是装载一个可执行程序然后运行它, 要不然就是动态的附加到一个运行的进程.Windows ...

  9. 《python灰帽子》学习笔记:调试器设置

    一.构造 C  数据类型 C Type | Python Type | ctypes Type ____________________________________________________ ...

随机推荐

  1. php 合并数组的方法 非array_merge

    Array ( [0] => Array ( [max] => 50 [date] => 2016-01-07 ) [1] => Array ( [max] => 100 ...

  2. Temporal Ensembling for Semi-Supervised Learning

    Laine, Samuli, and Timo Aila. "Temporal Ensembling for Semi-Supervised Learning." arXiv pr ...

  3. python 多线程糗事百科案例

    案例要求参考上一个糗事百科单进程案例 Queue(队列对象) Queue是python中的标准库,可以直接import Queue引用;队列是线程间最常用的交换数据的形式 python下多线程的思考 ...

  4. jquery图片上传前预览剪裁

    http://www.webmotionuk.co.uk/jquery/image_upload_crop.php http://keleyi.com/a/bjad/liuvpkke.htm 不错的d ...

  5. page coloring小结

    页着色是一种通过选择性物理页分配来实现把虚存映射到特定cache位置的软件方法. 最早引入页着色概念是在计算机体系结构,是为了解决地址别名问题引入的. 首先对cache是使用虚拟地址还是物理地址的问题 ...

  6. VS2013远程调试IIS中的网站

    问题描述一般网站发布到远程iis中了.我们就无法调试了... 今天查到个可以远程调试iis或winform的方法: 记录下 第一步:copy 本地 C:\Program Files (x86)\Mic ...

  7. VS中常用的环境变量

    环境变量名 含义 $(SolutionDir) 解决方案目录:即.sln文件所在路径 $(ProjectDir) 项目根目录:, 即.vcxproj文件所在路径 $(Configuration) 当前 ...

  8. ADO访问Oracle数据库,连接异常(Unknown error 0x800a0e7a)

    ADO访问Oracle数据库,连接异常(Unknown error 0x800a0e7a) 代码如下:执行Open过程中出现异常,信息为Unknown error 0x800a0e7a  C++ Co ...

  9. Ubuntu中su认证失败

    Ubuntu安装后,root用户默认是被锁定了的,不允许登录,也不允许 su 到 root 解决方法 sudo -i,输入当前用户密码后以root权限登录shell,无时间限制.使用exit或logo ...

  10. React课程学习

    http://guoyongfeng.github.io/idoc/index.html