py3k: converting int to bytes

J. Gerlach gerlach_joerg at web.de
Sat Feb 26 12:26:20 CET 2011


Am 24.02.2011 17:19, schrieb spam at uce.gov:
> 
> Is there a better way to convert int to bytes then going through strings:
> 
> x=5
> str(x).encode()
> 
> 
> Thanks.
> 
    >>> bytes([8])
    b'\x08'
seems more straight forward...



More information about the Python-list mailing list