Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I want to take this string '01101011' as an 0b01101011 integer in Python.I couldn't find any method to do that.I tried:
'01101011
0b01101011
a=a+"0b" a=int(a)
But is has no use.Can you help me guys?
a='01101011'
a = int(a, 2)
String to bitstring: Convert the string to integer then to binarystring.
>>> a_str = '101011' >>> a_bit_str = bin(int('101011',2)) >>> a_bit_str '0b101011'
String to Integer: If you just want to convert string to integer
>>> int(a_str,2) 43
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
a='01101011', thena = int(a, 2)