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
Convert the string to an integer base 16 then to hexadecimal.
print hex(int(string, base=16))
These are built-in functions.
http://docs.python.org/2/library/functions.html#int
Example
>>> string = 'AA' >>> _int = int(string, base=16) >>> _hex = hex(_int) >>> print _int 170 >>> print _hex 0xaa >>>