This is nothing but the encoding of any other file ...
import base64 with open('input.zip', 'rb') as fin, open('output.zip.b64', 'w') as fout: base64.encode(fin, fout)
Note. This avoids reading the file into memory for encoding it, so it should be more efficient.
source share