I\'m trying to find a way to print a string in hexadecimal. For example, I have this string which I then convert to its hexadecimal value.
my_string = \"deadbeef
A way that will fail if your input string isn't valid pairs of hex characters...:
>>> import binascii >>> ' '.join(hex(ord(i)) for i in binascii.unhexlify('deadbeef')) '0xde 0xad 0xbe 0xef'