请向我解释一下它们之间的区别?这两种指数在Python中有什么区别
import math
print math.exp(2)
print
print 2 ** 3
============================
7.38905609893
8
请向我解释一下它们之间的区别?这两种指数在Python中有什么区别
import math
print math.exp(2)
print
print 2 ** 3
============================
7.38905609893
8
您平方e为math.exp(2)
,E是2.71828183,见here
随着2 ** 3
,你正在提高2到三次方。
math.exp(2)
是e
提高到第二次方,2 ** 3
是2次提高到第3次方。
你很困惑math.exp()
与math.pow()
:math.pow(2, 3) == float(2**3)
。