Python String To Hex, 5+, encode the string to bytes and use the hex() method, returning a string.