【问题标题】:Checking arguments of a function in ipython在 ipython 中检查函数的参数
【发布时间】:2016-02-20 22:38:32
【问题描述】:

我正在使用 anaconda 的 jupyter ipython notebook。

有没有像RStudio 那样快速查看函数参数的方法?例如?merge 在 RStudio 的右下方窗口中显示合并文档。

我专门寻找 matplotlib.figure() 的参数,我在这里找到了,但这很耗时:http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.figure

找到与问题相关的帖子:Getting list of parameter names inside python function

但不确定是不是同一个问题。

【问题讨论】:

    标签: python python-2.7 ipython


    【解决方案1】:

    导入matplotlib后可以试试help(matplotlib.figure)

    【讨论】:

    • 当然,但这是 ipython,它有 object?,更短且更有帮助。
    • @MartijnPieters 好的...你的意思是 help 在 IPython 中不起作用...我不熟悉它,我承认
    • 不,help() 有效,但 ipython 有更好的 设施可用。
    【解决方案2】:

    在命令提示符下输入matplotlib.figure?,它会给你签名和文档:

    In [1]: import matplotlib
    
    In [2]: matplotlib.figure?
    Type:        module
    String form: <module 'matplotlib.figure' from '~/venv/lib/python2.7/site-packages/matplotlib/figure.pyc'>
    File:        ~/venv/lib/python2.7/site-packages/matplotlib/figure.py
    Docstring:
    The figure module provides the top-level
    :class:`~matplotlib.artist.Artist`, the :class:`Figure`, which
    contains all the plot elements.  The following classes are defined
    
    :class:`SubplotParams`
        control the default spacing of the subplots
    
    :class:`Figure`
        top level container for all plot elements
    

    来自IPython introduction

    探索你的对象

    键入object_name? 将打印关于任何对象的各种详细信息,包括文档字符串、函数定义行(用于调用参数)和类的构造函数详细信息。要获取对象的特定信息,可以使用魔术命令%pdoc%pdef%psource%pfile

    您也可以使用标准 Python help() function;输出有点冗长且没有颜色,就像 ipython object? 命令一样。

    【讨论】:

      猜你喜欢
      • 2015-08-31
      • 1970-01-01
      • 1970-01-01
      • 2017-05-29
      • 2012-12-26
      • 1970-01-01
      • 1970-01-01
      • 2013-02-18
      • 1970-01-01
      相关资源
      最近更新 更多