May-24-2021, 08:48 AM
There is no "hex integer". There are just integers. When python displays an integer with the default string representation, it's as a decimal.
In other words, why do you want
In other words, why do you want
[0x74, 0x65, 0x73, 0x74]
instead of [116, 101, 115, 116]
? If it's to display, you can print it that way. Otherwise, it shouldn't matter.>>> [ord(x) for x in "test"] [116, 101, 115, 116] >>> print("[" + ", ".join(hex(ord(x)) for x in "test") + "]") [0x74, 0x65, 0x73, 0x74]