在终端阅读 python 文档?

新手上路,请多包涵

有没有办法安装 python 文档,使其像联机帮助页一样可用? (我知道您可以下载文档的源文件并在 vim 中阅读它们,使用 less 或其他任何东西,但我正在考虑一些不那么手动的东西。不想自己动手。)

原文由 Var87 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 503
2 个回答

如果这是您想要的,我不知道,但您可以在 IDLE 中执行的所有操作都可以在命令行上执行。例子:

 C:>python
>>help(print())
>>help(plt.plot())

这样您就可以访问文档

原文由 GiodoAldeima 发布,翻译遵循 CC BY-SA 3.0 许可协议

它不是文档的精确副本,而是内置的 help() 函数

在交互式 python 会话中,您只需调用 help(whatever_you_want_to_read_about) ,例如:

 >>> help(all)
Help on built-in function all in module builtins:

all(...)
    all(iterable) -> bool

    Return True if bool(x) is True for all values x in the iterable.
    If the iterable is empty, return True.


或者,您可以像这样启动交互式帮助会话:

 C:\Users\Rawing>python -c "help()"

Welcome to Python 3.4!  This is the interactive help utility.

help>

然后只需键入您想了解的函数/类/模块:

 help> all
Help on built-in function all in module builtins:

all(...)
    all(iterable) -> bool

    Return True if bool(x) is True for all values x in the iterable.
    If the iterable is empty, return True.

原文由 Aran-Fey 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题