python - 放置一个“?” 在函数名之后了解更多关于函数的信息
问题描述
教科书说“要了解有关函数的更多信息,请在其名称后放置一个?。例如,键入 math.log?将在数学模块中显示对 log 函数的描述。”
我尝试在 Jupyter Notebook 中实现此示例,但出现错误。为什么?
import math
math.log?
^ SyntaxError: invalid syntax
解决方案
您可以__doc__
用来获取函数的文档字符串:
和 ?:
math.log?
输出:
Docstring:
log(x[, base])
Return the logarithm of x to the given base.
If the base not specified, returns the natural logarithm (base e) of x.
Type: builtin_function_or_method
与__doc__
:
math.log.__doc__
输出:
log(x[, base])\n\nReturn the logarithm of x to the given base.\nIf the base not specified, returns the natural logarithm (base e) of x.
推荐阅读
- google-sheets - 当布局不同时,如何从 2 个范围进行查询?
- php - Boostrap 表单验证成功消息未出现
- python - 在循环数据框 Pandas 时跳过行
- azure-devops - 在 portal.azure.com 项目中显示 dev.azure.com 项目
- abap - SAP Smartforms 动态更改某些项目的位置
- python - 2 路 Socket 通过蓝牙进行通信
- javascript - 如果鼠标在移动,则生成一个 scipt 以每 n 秒检查一次
- c++ - C++ 临时优步应用程序
- php - 使用 C9。无法使用 PHP 连接到 MySQL 数据库
- python - 使用 spyder 时如何获取函数的“帮助”?