名称'e'未定义我的python代码中出现此错误。我已经导入了 math 和 numpy 模块。我还需要什么?
2 回答
0
尝试:
from math import e
您现在可以在代码中使用“e”
或者
import math
math.e
math.e 将在您的代码中用作浮点数
于 2020-07-13T05:02:13.413 回答
0
采用
import math
math.e
类似的,例如:
import math
math.pi
通过这种方式,可以清楚地知道哪个e
(或)或意味着什么,而不是代码中某处pi
的随机字母。e
如果您改用 NumPy,则可以执行以下操作:
import numpy as np
np.e
(NumPy 导入通常缩写为np
)。
两者e
都是一样的。
于 2020-07-13T05:08:11.613 回答