I\'ve been reading up a lot on stuct.pack and hex and the like.
I am trying to convert a decimal to hexidecimal with 2-bytes. Reverse the hex bit order, then convert
Print formatting also works with strings.
# Get the hex digits, without the leading '0x'
hex_str = '%04X' % (36895)
# Reverse the bytes using string slices.
# hex_str[2:4] is, oddly, characters 2 to 3.
# hex_str[0:2] is characters 0 to 1.
str_to_convert = hex_str[2:4] + hex_str[0:2]
# Read back the number in base 16 (hex)
reversed = int(str_to_convert, 16)
print(reversed) # 8080!