1 pythonCopy>>> (258).to_bytes(2, byteorder="little")
2b'\x02\x01'
3>>> (258).to_bytes(2, byteorder="big")
4b'\x01\x02'
5>>> (258).to_bytes(4, byteorder="little", signed=True)
6b'\x02\x01\x00\x00'
7>>> (-258).to_bytes(4, byteorder="little", signed=True)
8b'\xfe\xfe\xff\xff'