hex(string)

Convert a string into a hexadecimal representation of the string. The input string can be binary data or a normal string.

Example
str = hex("Hello world!")