I did this line of code and i got this error ” File “C:\Python33\lib\base64.py”, line 326, in encode
output.write(line)
TypeError: must be str, not bytes”
import base64
with open('trang_base64.wav', 'rb') as fin, open('output.b64', 'w') as fout:
base64.encode(fin, fout)
What’s wrong with the code above?
I think you need to set the output to be in binary mode:
open(‘output.b64’, ‘wb’)
Python3 assumes text mode unless you specify:
http://docs.python.org/3.3/tutorial/inputoutput.html#reading-and-writing-files