Q:

How to change a string to hex

So I have this normal string and I want to get its hex value in Python. 
Example:
":" I want the program to output "0x3a" 
However I searched didn't find anything here.  Do you know how to do this? 

A:

Python2 has this easy way
>>> "Hello".encode("hex")
'48656c6c6f'

Python3 is not so bad
>>> import binascii
>>> binascii.hexlify(b'Hello')
b'48656c6c6f'

