Size of files compressed with python gzip module is not reduced
问题 I made a simple test code that generates a lot of integers and writes them into a compressed file using the gzip module. import gzip for idx in range(100000): with gzip.open('output.gz', 'ab') as f: line = (str(idx) + '\n').encode() f.write(line) The compressed file is created but when I decompress it, the raw data are actually a lot smaller: $ ls -l 588890 output 3288710 output.gz Can you please explain what am I doing wrong here? 回答1: The assumption that append mode would append to the