pow()与math.pow()函数怎么在Python中使用?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
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**2
9
>>> pow(3,2,4)# (3**2)%4
1
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
>>>
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注天达云行业资讯频道,感谢您对天达云的支持。