Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to xor binary with python

Tags:

python

binary

xor

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

1 Answers

a="11011111101100110110011001011101000"
b="11001011101100111000011100001100001"
y=int(a,2) ^ int(b,2)
print('{0:b}'.format(y))
like image 168
Robᵩ Avatar answered Sep 07 '25 22:09

Robᵩ