马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 永恒的蓝色梦想 于 2020-4-10 18:45 编辑
Python pow() 函数
语法
描述
进行乘方运算的函数。
参数
参数 | 描述 | base | 底数 | exp | 指数 | mod | 取模运算用的值。若提供该参数,则3个参数必须都为 int。 |
返回值
如果提供两个参数,则返回值为 base**exp。
如果提供三个参数,则返回值为 base**exp % mod。
例子
>>> pow(6,7,None)
279936
>>> pow(6,7)#提供2个 int 参数
279936
>>> pow(6.0,7.0)提供2个 float 参数
279936.0
>>> pow(6,7,8)#提供第3个参数并且所有参数为 int
0
>>> pow(6.0,7.0,8.0)#提供第3个参数但所有参数不为 int
Traceback (most recent call last):
File "<pyshell#51>", line 1, in <module>
pow(6.0,7.0,8.0)
TypeError: pow() 3rd argument not allowed unless all arguments are integers
|