help
的界面更像由pydoc
模块提供,尤其是其未公开的方法pager
。如果您将数据转换为字符串(也许通过使用pprint
模块以提高可读性),则可以将其发送到pager
以获得所需的交互式可视化效果。
>>> import pydoc
>>> import pprint
>>> def more_vars(obj):
... pydoc.pager(pprint.pformat(vars(obj)))
...
>>> import math
>>> more_vars(math)
{'__doc__': 'This module provides access to the mathematical functions\n'
'defined by the C standard.','__loader__': <class '_frozen_importlib.BuiltinImporter'>,'__name__': 'math','__package__': '',[not pictured: about 30 more lines of methods/attributes]
'frexp': <built-in function frexp>,'fsum': <built-in function fsum>,'gamma': <built-in function gamma>,-- More --
本文链接:https://www.f2er.com/3165223.html