本文實例講述了Python中pow()和math.pow()函數用法。分享給大家供大家參考,具體如下:
1. 內置函數pow()
>>> help(pow)Help on built-in function pow in module __builtin__:pow(...) pow(x, y[, z]) -> number With two arguments, equivalent to x**y. With three arguments, equivalent to (x**y) % z, but may be more efficient (e.g. for longs).>>>>>> pow(3,2) # 3**29>>> pow(3,2,4)# (3**2)%41
2. math.pow()
>>> import math>>> help(math.pow)Help on built-in function pow in module math:pow(...) pow(x, y) Return x**y (x to the power of y).>>> math.pow(3,2)9.0>>>
希望本文所述對大家Python程序設計有所幫助。
新聞熱點
疑難解答