exp**2为什么会产生错误“unsupported operand type(s)for**”?

2024-04-25 14:58:25 发布

您现在位置:Python中文网/ 问答频道 /正文

为什么会产生错误?在

>>> from math import exp
>>> exp**2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for ** or pow(): 'builtin_function_or_method' and 'int'

Tags: orinfromimportmost错误stdinline
1条回答
网友
1楼 · 发布于 2024-04-25 14:58:25

exp**必须是exp或{}(在后一种情况下,from math import e)。math.exp不是常数e的名称,而是指数函数。在

>>> exp(2)
7.38905609893065
>>> from math import e
>>> e**2
7.3890560989306495

相关问题 更多 >

    热门问题