How to get an integer from a sequence of bytes
Chris Angelico
rosuav at gmail.com
Sun Jun 2 15:54:11 EDT 2013
On Mon, Jun 3, 2013 at 5:25 AM, Mok-Kong Shen <mok-kong.shen at t-online.de> wrote:
> b'7' is the byte with the character 7 in a certain code, so that's
> ok. In other PLs one assigns an int to a byte, with that int in either
> decimal notation or hexadecimal notation, or else one assigns a
> character to it, in which case it gets the value of the character
> in a certain code. What I don't yet understand is why Python is
> apprently different from other PLs in that point in not allowing direct
> coersion of a byte to an int.
It does. Just subscript it:
>>> b'7'[0]
55
ChrisA
More information about the Python-list
mailing list