【发布时间】:2011-12-12 19:36:27
【问题描述】:
我需要临时创建一些文件的解压缩版本。我见过有人在 bash 中做zcat somefile.gz > /tmp/somefile,所以我在 python 中做了这个简单的函数:
from subprocess import check_call
def unzipto(zipfile, tmpfile):
with open(tmpfile, 'wb') as tf:
check_call(['zcat', zipfile], stdout=tf)
但使用 zcat 和 check_call 对我来说似乎很老套,我想知道是否有更多“pythonic”方式来做到这一点。
感谢您的帮助
【问题讨论】:
-
“暂时”是什么意思?你需要它做什么?