In [75]: x=4
In [76]: y=1
In [77]: str(bin(x ^ y))[2:].count('1')
Out[77]: 2
In [78]:
来自:https://leetcode.com