What does the ** maths operator do in Python?

前端 未结 5 1948
星月不相逢
星月不相逢 2020-12-18 18:24

What does this mean in Python:

sock.recvfrom(2**16)

I know what sock is, and I get the gist of the recvfrom function, but what

5条回答
  •  一生所求
    2020-12-18 18:57

    It is the power operator.

    From the Python 3 docs:

    The power operator has the same semantics as the built-in pow() function, when called with two arguments: it yields its left argument raised to the power of its right argument. The numeric arguments are first converted to a common type, and the result is of that type.

    It is equivalent to 216 = 65536, or pow(2, 16)

提交回复
热议问题