Python3 探索模块内容帮助 help dir

  • dir(sys) : 该函数会返回一个列表,其中包含了对象的所有属性的字符串名称. 这是一种在交互模式下唤醒对模块的记忆的便捷方式.

  • print(sys.__doc__) : 如果还不够,我们还可以查看模块的 __doc__ 字符串.

  • help(sys): 用更好的格式 显示帮助

import sys

print(dir(sys))
# 输出(省略了部分内容
"""
['__displayhook__', '__doc__', '__excepthook__', '__interactivehook__', '__loader__', '__name__', 
'__package__', '__spec__', '__stderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_current_frames', 
'_debugmallocstats', '_enablelegacywindowsfsencoding', '_getframe', '_git', '_home', '_xoptions', 'api_version',
 'argv',  ... , 'version', 'version_info', 'warnoptions', 'winver']
"""

print(sys.__doc__)

help(sys)

猜你喜欢

转载自blog.csdn.net/weixin_34363171/article/details/87213318