【问题标题】:IPython and __doc__IPython 和 __doc__
【发布时间】:2013-06-28 02:12:08
【问题描述】:

我使用的是IPython,它是从“Enthought Python Distribution”下载的

在IPython / Python 2.7.3下,当我输入help(__doc__)时,结果是:

In  [26]: help(__doc__)
no Python documentation found for 'Automatically created module for IPython interactive environment'

这个结果是什么意思? IPython 不支持?

谢谢!

【问题讨论】:

  • __doc__ 是一个字符串。这些就是它的内容。
  • 问题是你想做什么? (通常在 IPython 中,您可以通过 object? 获得帮助)

标签: python-2.7 ipython


【解决方案1】:

正如@Blender 所说,__doc__ 只是一个字符串,通常是给定函数或模块的帮助字符串。例如,

In [1]: numpy.__doc__
Out[1]: '\nNumPy\n=====\n\nProvides\n  1. An array object of arbitrary homogeneous items\n  2. Fast mathematical operations over arrays\n ...

numpy 模块的帮助字符串。在numpy 上调用help() 基本上只是打印出这个字符串的格式良好的版本:

Help on package numpy:

NAME
    numpy

FILE
    /usr/lib64/python2.6/site-packages/numpy/__init__.py

DESCRIPTION
    NumPy
    =====

    Provides
      1. An array object of arbitrary homogeneous items
      2. Fast mathematical operations over arrays
      ...

在 IPython 中,字符串 __doc__ 只是:

In [3]: __doc__
Out[3]: 'Automatically created module for IPython interactive environment'

调用help(__doc__) 然后查找__doc__.__doc__,它不存在。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-21
    • 1970-01-01
    • 2015-04-24
    • 2011-08-28
    • 1970-01-01
    • 1970-01-01
    • 2015-06-18
    相关资源
    最近更新 更多