Answers for "convert int to byte python"

0

convert int to byte python

pythonCopy>>> (258).to_bytes(2, byteorder="little")
b'\x02\x01'
>>> (258).to_bytes(2, byteorder="big")
b'\x01\x02'
>>> (258).to_bytes(4, byteorder="little", signed=True)
b'\x02\x01\x00\x00'
>>> (-258).to_bytes(4, byteorder="little", signed=True)
b'\xfe\xfe\xff\xff'
Posted by: Guest on September-06-2020
0

int to byte array python

>>> bytes([2])
b'\x02`
Posted by: Guest on August-31-2020

Python Answers by Framework

Browse Popular Code Answers by Language