Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
780 views
in Technique[技术] by (71.8m points)

how to xor binary with python

I'm trying to xor 2 binaries using python like this but my output is not in binary any help?

a = "11011111101100110110011001011101000"
b = "11001011101100111000011100001100001"
y = int(a) ^ int(b)
print y
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
a = "11011111101100110110011001011101000"
b = "11001011101100111000011100001100001"
y = int(a,2) ^ int(b,2)
print '{0:b}'.format(y)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...