I want to convert a string consists of binary digits and convert that string into a binary number.
suppose, my input is "01001", this is in string format, i want to convert this to binary number format to perform various bit wise operations on that.
I want to convert a string consists of binary digits and convert that string into a binary number.
suppose, my input is "01001", this is in string format, i want to convert this to binary number format to perform various bit wise operations on that.
You can convert the number to an int and do bitwise operations, like this
my_int = int("01001", 2)
print my_int & 1 # 1
print my_int & 8 # 8
print my_int & 16 # 0