I know it's been asked on this site, but I admit I didn't understand the answer to this question.
In Python 3, there is the 'binary literal', which is expressed by prefixing a string with a b
. E.g.:
b'hello world'
I understand that this turns the string into a bytes
object. But, a string is already a sequence of bytes underneath, isn't it? So what do this actually do for us? Also, using what encoding does this encode the string to bytes?
Please clear things up for me. I am referring specifically to Python 3.