I want to write a file. Based on the name of the file this may or may not be compressed with the gzip module. Here is my code:
gzip
import gzip filen
you can convert it to bytes like this.
import gzip with gzip.open(filename, 'wb') as fd: fd.write('blah blah blah'.encode('utf-8'))