Python b string consists of bytes data, meaning the literal representing integers is between 0 and 255. The main difference between Python b string and Python string is its data type. The normal string has a sequence of Unicode characters like UTF-16 or UTF-32, whereas the Python b string has bytes data type means the literals that represent integers between 0 and 255 (also known as octets).
By adding that prefix b in front of a normal python string, we modified its data type from string to bytes.
Example
app_string = 'Happiest Season'
print(type(app_string))
app_string_b = b'Happiest Season'
print(type(app_string_b))
Output
<class 'str'>
<class 'bytes'>
You can see that the first is a normal string, and the second has bytes.
The second object you are printing is not a string but rather a byte object as a byte literal.
The datatype is a Byte type object in Python 2.x, str, and bytes, but in Python 3.x, this is changed now.
That’s it.
Hey, nice article and I like your website 🙂
I am German so I just wanted to let you know that the “German word” used in the example “ÑÞ” is definitely not German. Both letters do not exist in the German alphabet.
Have a nice day