python3 string type byte type conversion - laucianexones/encryptBackup GitHub Wiki

data_to_compress = "ıüğşçö"
print(type(data_to_compress))

b = bytes(data_to_compress, "utf-8")
print(type(b))
print(b)

<class 'str'>
<class 'bytes'>
b'\xc4\xb1\xc3\xbc\xc4\x9f\xc5\x9f\xc3\xa7\xc3\xb6'

print(b.decode('utf-8'))
ıüğşçö

http://eli.thegreenplace.net/2012/01/30/the-bytesstr-dichotomy-in-python-3