How to get a single byte in a string of bytes, without converting to int How to get a single byte in a string of bytes, without converting to int python-3.x python-3.x

How to get a single byte in a string of bytes, without converting to int


Extract it as a range:

str_of_bytes[1:2]

Result:

b'd'

This is the same as b'\x64'

Note that I'm assuming you're using Python 3. Python 2 behaves differently.