Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

convert int to byte python

 pythonCopy>>> (258).to_bytes(2, byteorder="little")
b'x02x01'
>>> (258).to_bytes(2, byteorder="big")
b'x01x02'
>>> (258).to_bytes(4, byteorder="little", signed=True)
b'x02x01x00x00'
>>> (-258).to_bytes(4, byteorder="little", signed=True)
b'xfexfexffxff'
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #convert #int #byte #python
ADD COMMENT
Topic
Name
4+8 =