python - 如何在Jupyter笔记本中转到函数的定义?

标签 python jupyter-notebook

如何在Jupyter中转到函数定义?

我想要Visual Studio的f12或Eclipse的ctrl + click之类的东西。

我很难相信这不存在,但找不到

最佳答案

我不知道这种功能适用于所有内核。

如果您使用的是Python内核并安装了ipython,则可以使用检查功能:

  • %pdoc <object>: Print (or run through a pager if too long) the docstring for an object. If the given object is a class, it will print both the class and theconstructor docstrings.
  • %pdef <object>: Print the call signature for any callable object. If the object is a class, print the constructor information.
  • %psource <object>: Print (or run through a pager if too long) the source code for an object.
  • %pfile <object>: Show the entire source file where an object was defined via a pager, opening it at the line where the object definition begins.
  • %who/%whos: These functions give information about identifiers you have defined interactively (not things you loaded or defined in your configuration files). %who just prints a list of identifiers and %whos prints a table with some basic details about each identifier.

Typing ??word or word?? gives access to the full information, including the source code where possible. Long strings are not snipped.



使用范例
In [4]: pd.DataFrame?

In [5]: pd.DataFrame??

In [6]: %pdef pd.Dataframe
Object `pd.Dataframe` not found.

In [7]: %pdef pd.DataFrame
Class constructor information:
 pd.DataFrame(data=None, index=None, columns=None, dtype=None, copy=False)

In [8]: %pdoc pd.DataFrame

In [9]: %pfile pd.DataFrame

资源

Dynamic object information

关于python - 如何在Jupyter笔记本中转到函数的定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53451028/

相关文章:

python - 无效语法错误 : Building decision tree with Python and Spark, 流失预测

python - 从配置文件 Python 中读取值

python - 从文件名中提取日期

docker - 无法在 Windows 10 中连接到 Tensorflow Jupyter Notebook

keras - 在 Jupyter notebook 中中断 keras 训练是否可以节省训练?

python - ISBN 12 至 13 位数字

python - 将 classification_report 的准确度返回到列表中

python - 系统退出 : 2 error when calling parse_args() within ipython

python - VSCode Jupyter 扩展 : Rich syntax highlighting not working?

css - 查找 jupyter notebook 用于数据框的默认 .css