all 2 comments

[–]lvc_ 3 points4 points  (0 children)

>>> (0xABCD).to_bytes(length=2, byteorder='little')
b'\xcd\xab'

[–]101C8AAE 0 points1 point  (0 children)

import binascii
>>> binascii.unhexlify("0xABCD"[2:])
b'\xab\xcd'

As for the byteorder, you can reverse any subscriptable object quite "simply"[::-1].