The method decode() decodes the string using the codec registered for encoding. It defaults to the default string encoding.
When you reading utf-8 encoded file, you need to use string.decode('utf8')
Write:
data = 'my data'
with open("file.txt" , "w") as f:
f.write(data.encode('utf-8'))
Read:
with open("file.txt" , "r") as f:
data = f.read().decode('utf-8')