我正在尝试对二进制值进行异或运算,但由于某种未知原因,我在转换中丢失了第一个 0。知道我做错了什么吗?
m1 = int('01010100011001010111001101110100',2)
c1 = int('00111001000001000001000000000001',2)
c2 = int('00111101000100110000110000010001',2)
kk = bin(m1 ^ c1)[2:]
xx = int(kk,2)
m2 = bin(xx ^ c2)[2:]
print m2
由于某种原因,这返回1010000011100100110111101100100
而不是01010000011100100110111101100100
,所以我失去了领先地位0
。