国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python pdb調(diào)試方法分享

2020-02-23 05:06:34
字體:
供稿:網(wǎng)友

代碼如下:
import pdb

def pdb_test(arg):
    for i in range(arg):
        print(i)
    return arg

pdb.run("pdb_test(3)")
 

 b 函數(shù)名、行號:

打斷點(diǎn),b可以查詢所有的斷點(diǎn)。
代碼如下:
(Pdb) b pdb_test
Breakpoint 1 at c:/users/plpcc/desktop/pdbtest.py:3
(Pdb) b
Num Type         Disp Enb   Where
   breakpoint   keep yes   at c:/users/plpcc/desktop/pdbtest.py:3
 

  c:

運(yùn)行程序,直到遇到斷點(diǎn)。
代碼如下:
(Pdb) c
> c:/users/plpcc/desktop/pdbtest.py(4)pdb_test()
-> for i in range(arg):

   l:

     查看斷點(diǎn)周圍的代碼
代碼如下:
(Pdb) l
    import pdb

B   def pdb_test(arg):
  ->      for i in range(arg):
             print(i)
       return arg

     pdb.run("pdb_test(3)")

 a:

    查看參數(shù)
代碼如下:
(Pdb) a
arg = 3

 s, n:

    單步運(yùn)行,區(qū)別s會進(jìn)入路徑中的函數(shù),n不會進(jìn)入

 p:

    查看表達(dá)式的值
代碼如下:
(Pdb) p i

 condition:
 

條件斷點(diǎn),只有條件為true斷點(diǎn)才命中
代碼如下:
> c:/users/plpcc/desktop/pdbtest.py(5)pdb_test()
-> print(i)
(Pdb) l
    import pdb

    def pdb_test(arg):
        for i in range(arg):
B->          print(i)
        return arg

    pdb.run("pdb_test(3)")
[EOF]
(Pdb) b
Num Type         Disp Enb   Where
breakpoint   keep yes   at c:/users/plpcc/desktop/pdbtest.py:5
(Pdb) condition 2 i==1   //i==1時才觸發(fā)斷點(diǎn)2
New condition set for breakpoint 2.
(Pdb) b
Num Type         Disp Enb   Where
breakpoint   keep yes   at c:/users/plpcc/desktop/pdbtest.py:5
 stop only if i==1
(Pdb) c
                    //i==0直接打印未斷住
> c:/users/plpcc/desktop/pdbtest.py(5)pdb_test()
-> print(i)             //觸發(fā)斷點(diǎn),i==1
(Pdb) p i

bt:

查看調(diào)用堆棧
代碼如下:
(Pdb) bt
c:/python33/lib/bdb.py(405)run()
-> exec(cmd, globals, locals)
<string>(1)<module>()

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 尼木县| 平邑县| 南平市| 攀枝花市| 稻城县| 汝阳县| 大厂| 慈溪市| 潜江市| 红河县| 宜都市| 和田市| 乌恰县| 周口市| 太和县| 新绛县| 子洲县| 宜昌市| 石渠县| 台东县| 肇源县| 赤壁市| 正阳县| 射阳县| 诸城市| 沂南县| 珲春市| 石首市| 株洲县| 鸡西市| 临漳县| 当雄县| 婺源县| 宁夏| 大名县| 威信县| 潼关县| 沾益县| 铜山县| 临安市| 阿瓦提县|