ZipFile

w mode creates; a appends.

import zipfile
with zipfile.ZipFile('out.zip', 'w') as z:
    z.write('file.txt')