Manual
Return x to the power y; if z is present, return x to the power y, modulo z (computed more efficiently than pow(x, y) % z). The two-argument form pow(x, y) is equivalent to using the power operator: x**y.
The arguments must have numeric types. With mixed operand types, the coercion rules for binary arithmetic operators apply. For int operands, the result has the same type as the operands (after coercion) unless the second argument is negative; in that case, all arguments are converted to float and a float result is delivered. For example, 10**2 returns 100, but 10**-2 returns 0.01. If the second argument is negative, the third argument must be omitted. If z is present, x and y must be of integer types, and y must be non-negative.
直译
返回x的y次方;如果存在z,返回x的y次方的z模(比计算pow(x, y) % z更有效)。构成pow(x, y)的两个参数等于使用幂运算:x**y。
参数必须是数值类型。针对二进制算术运算符的强制规则,应用混合运算数类型。对于整型运算数,结果与运算数的类型相同,除非第二个参数是负数,这种情况下,所有参数转化为浮点型,并返回浮点型结果。例如:10**2返回100,但10**-2返回0.01。如果第二个参数是负值,则第三个参数必须缺省。如果出现z,x和y必须是整数类型,且y必须为非负。
实例
>>> pow(3, 2)
9
>>> pow(3, 2, 5)
4
>>> 3 ** 2 % 5
4
>>> pow(3, 0.2, 5)
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
pow(3, 0.2, 5)
TypeError: pow() 3rd argument not allowed unless all arguments are integers
>>> pow(100, -2)
0.0001
>>> pow(10, -2)
0.01
>>> pow(10, -2, 3)
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
pow(10, -2, 3)
ValueError: pow() 2nd argument cannot be negative when 3rd argument specified