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'