【问题标题】:How to show function parameters in IPython?如何在 IPython 中显示函数参数?
【发布时间】:2015-12-21 10:11:19
【问题描述】:

我读到在一个函数在 IPython 笔记本中显示该函数的文档字符串后按 shift+tab,但这似乎不适用于我的 IPython(没有笔记本)。我在 Ubuntu 上运行 IPython 4.0.0。

有什么建议吗?

【问题讨论】:

  • 在命令后面输入一个问号

标签: ipython


【解决方案1】:

标准(控制台)IPython 不支持通过<shift> + <tab> 调用提示。但是函数之前或之后的问号会显示文档字符串:

In [1]: list.index?
Docstring:
L.index(value, [start, [stop]]) -> integer -- return first index of value.
Raises ValueError if the value is not present.
Type:      method_descriptor  

您也可以使用 qtconsole 版本:

ipython qtconsole

然后:

In [1]: list.index(

应该在不按<shift> + <tab> 的情况下向您显示一个带有呼叫提示的框:

【讨论】:

  • 为了让它工作,我必须运行pip install qtconsole PyQt5。此外,这似乎将在未来重命名为:jupyter qtconsole
【解决方案2】:

Tab+Shift,适用于jupyter notebook 5.6.0版本。

【讨论】:

  • 提问者明确表示这不是笔记本。
猜你喜欢
  • 2018-01-11
  • 2014-11-16
  • 2015-08-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多