Python解释器模式-探索Python模块及其用法的几种方法 [英] Python Interpreter Mode - What are some ways to explore Python's modules and its usage

查看:77
本文介绍了Python解释器模式-探索Python模块及其用法的几种方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Python解释器中:

While inside the Python Interpreter:

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

What are some ways to learn about the packages I have?

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

SyntaxError:语法无效

SyntaxError: invalid syntax

>>> 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,但是所有这些东西都已经包含在内,我希望不重复文件.

Now, how do I see all the packages available to me on my sys.path? And see their subsequent usage and documentation. I know that I can easily download a PDF but all this stuff is already baked in, I'd like to not duplicate files.

谢谢!

推荐答案

您可以查看help("modules"),它显示可用模块的列表. 要探索特定的模块/类/功能,请使用dir__doc__:

You can look at help("modules"), it displays the list of available modules. To explore a particular module/class/function use dir and __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.

这篇关于Python解释器模式-探索Python模块及其用法的几种方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆