Fix Python – How to convert ‘binary string’ to normal string in Python3?

For example, I have a string like this(return value of subprocess.check_output):
>>> b’a string’
b’a string’

Whatever I did to it, it is always printed with the annoying b’ before the string:
>>> print(b’a string’)
b’a string’
>>> print(str(b’a string’))
b’a string’

Does anyone have any ideas about how to use it as a normal string or convert it ….

Fix Python – How do you express binary literals in Python?

How do you express an integer as a binary number with Python literals?
I was easily able to find the answer for hex:
>>> 0x12AF
>>> 0x100

and octal:
>>> 01267
>>> 0100

How do you use literals to express binary in Python?

Summary of Answers

Python 2.5 and earlier: can express binary using int(‘01010101111’,2) but not with a lite….

Fix Python – What does the ‘b’ character do in front of a string literal?

Apparently, the following is the valid syntax:
b’The string’

I would like to know:

What does this b character in front of the string mean?
What are the effects of using it?
What are appropriate situations to use it?

I found a related question right here on SO, but that question is about PHP though, and it states the b is used to indicate the st….