python中pow(x,y)和x**y有什么区别
是一样的吗?一样 效果一样 区别呢,嗯,pow(x,y)是BIF,你把他覆盖了就用不了,但x**y没影响
def pow(x,y):
return y**x
pow(x,y)
x**y
不过,我们没事也不会去覆盖它,所以你可以当他们没区别 那个,抱歉,我说的的准确。我去看了一下,python这么解释的:
Help on built-in function pow in module builtins:
pow(x, y, z=None, /)
Equivalent to x**y (with two arguments) or x**y % z (with three arguments)
Some types, such as ints, are able to use a more efficient algorithm when
invoked using the three argument form.
pow()有三个参数
pow(2,8,7)
2**8%7
这两个是等价的
即 pow(x,y,z) == x**y%z
页:
[1]