# convert text string to hexa decimal code str = 'twee'.encode('utf-8') hex = str.hex() # convert hexadecimal code to string str1 = bytes.fromhex(hex).decode('utf-8') print(hex) print(str1)