如何在Python PDB中显示线程/进程ID?

Hem*_*Hem 4 python pdb

在Python中,有没有办法在使用PDB进行调试时显示线程/进程ID?

我在看https://docs.python.org/2/library/pdb.html但找不到与之相关的任何内容?

shx*_*hx2 5

(pdb) import os,threading; os.getpid(), threading.current_thread().ident
Run Code Online (Sandbox Code Playgroud)

如果您经常需要这样做,在.pdbrc文件中添加别名会很方便:

alias tid import os,threading;; p os.getpid(), threading.current_thread().ident
Run Code Online (Sandbox Code Playgroud)

  • 我不知道 pdbrc。谢谢你的奖金提示。 (2认同)