加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

Python解释器模式 – 有哪些方法可以探索Python的模块及其用法

发布时间:2020-12-20 12:22:03 所属栏目:Python 来源:网络整理
导读:在 Python解释器中: 有什么方法可以了解我的包装? man sysFile "stdin",line 1 man sys ^ SyntaxError:语法无效 sys --helpTraceback (most recent call last): File "stdin",line 1,in moduleTypeError: bad operand type for unary -: '_Helper' 更正:
在 Python解释器中:

有什么方法可以了解我的包装?

>>> man sys
File "<stdin>",line 1
    man sys
      ^

SyntaxError:语法无效

>>> sys --help
Traceback (most recent call last):
  File "<stdin>",line 1,in <module>
TypeError: bad operand type for unary -: '_Helper'

更正:

>>> help(sys)
...

现在,我如何在sys.path上看到我可以使用的所有软件包?并查看其后续使用和文档.我知道我可以轻松下载PDF,但所有这些东西已经出炉了,我不想复制文件.

谢谢!

解决方法

您可以查看帮助(“模块”),它显示可用模块的列表.
要探索特定的模块/类/函数,请使用dir和__doc__:

>>> import sys
>>> sys.__doc__
"This module ..."

>>> dir(sys)
[...,'setprofile',...]

>>> print(sys.setprofile.__doc__)
setprofile(function)

Set the profiling function.  It will be called on each function call
and return.  See the profiler chapter in the library manual.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读