Why does Python `**` use for exponentiation instead of the `^` operator? [duplicate]
问题 This question already has answers here : What do these operators mean (** , ^ , %, //)? [closed] (3 answers) Closed 2 years ago . Why is ^ not squaring in Python? I know exponentiation is ** instead, but what exactly is ^ and why wasn't that operator used instead? For example 2^2=0 , 3^2=1 . 回答1: The ^ operator was already used for bitwise xor. >>> x = 42; format(x, '08b') '00101010' >>> y = 137; format(y, '08b') '10001001' >>> z = x ^ y; format(z, '08b') '10100011' That leaves the old