Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python bytes

>>> (1024).to_bytes(2, byteorder='big')
b'x04x00'
>>> (1024).to_bytes(10, byteorder='big')
b'x00x00x00x00x00x00x00x00x04x00'
>>> (-1024).to_bytes(10, byteorder='big', signed=True)
b'xffxffxffxffxffxffxffxffxfcx00'
>>> x = 1000
>>> x.to_bytes((x.bit_length() + 7) // 8, byteorder='little')
b'xe8x03'
Source by docs.python.org #
 
PREVIOUS NEXT
Tagged: #Python #bytes
ADD COMMENT
Topic
Name
2+8 =