Hope someone can help me with the following. It may not be too difficult, but I could not figure it out. My file "output.txt" is created with:
f = open('output.txt', 'w')
print(tweet['text'].encode('utf-8'))
print(tweet['created_at'][0:19].encode('utf-8'))
print(tweet['user']['name'].encode('utf-8'))
f.close()
If I do not encode it to write to a file, this will give me errors. Thus, the "output" contains 3 lines of output encoded with utf-8:
b'testtesttest'
b'line2test'
b'\xca\x83\xc9\x94n ke\xc9\xaan'
In "main.py", I am trying to convert this back to a string:
f = open("output.txt", "r", encoding="utf-8")
text = f.read()
print(text)
f.close()
Unfortunately, b '' format has not been deleted yet. Should I still decode it? If possible, I would like to keep the structure of 3 lines. My apologies for the newbies question, this is my first on SO :)
Thank you so much in advance!