教科书说:“要了解有关函数的更多信息,请在函数名称后加上?。例如,键入math.log?将在math模块中显示对数函数的描述。”
我尝试在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.
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句