I would like to save bytes to a file and then read that file as a text. Can I do it with one with
? What should I use, wb
, r
or wbr
?
myBytesVar = b'line1\nline2'
with open('myFile.txt', 'wb') as fw:
fw.write(myBytesVar)
with open('myFile.txt', 'r') as fr:
myVar = fr.read()
print(myVar)