請向我解釋一下它們之間的區別?這兩種指數在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)
。