我是pdb的新手,所以也许这是我的shell或我如何运行它的问题,但pp
似乎没有正确显示字典
我有此代码:
#!/usr/bin/env python3
import os
def get_path(filename):
"""Return file's path or empty string if no path."""
test = {1: 'Geeks', 2: 'For', 3: 'Geeks', 1: [1, 2, 3, 4]}
head, tail = os.path.split(filename)
import pdb; pdb.set_trace()
return head
filename = __file__
print(f'path = {get_path(filename)}')
我运行文件并放入调试器,并尝试漂亮地打印字典:
❯ /usr/local/opt/python/bin/python3.7 /Users/me/test/test.py
> /Users/me/test/test.py(12)get_path()
-> return head
(Pdb) pp test
{1: [1, 2, 3, 4], 2: 'For', 3: 'Geeks'}
(Pdb)
该字典应该缩进几行吗?那就是我导入和使用pp库时看到的内容