【发布时间】:2015-10-30 16:57:36
【问题描述】:
我正在尝试修改 gzip 压缩文件。 这是我的代码:
with tempfile.TemporaryFile() as tmp:
with gzip.open(fname, 'rb') as f:
shutil.copyfileobj(f, tmp)
# do smth here later
with gzip.open(fname, 'wb') as f:
shutil.copyfileobj(tmp, f)
我删除了所有修改,只留下了读写。在输出时,我得到空的 gzip 文件。这有什么问题? (Python 2.7.6,Linux)
【问题讨论】: