gzip Python中的文件
我想用Python压缩文件。我正在尝试使用subprocss.check_call(),但是它始终失败,并显示错误“ OSError:[Errno 2]
No such file or
directory”。我在这里尝试的内容有问题吗?是否有比使用subprocess.check_call更好的gzip文件压缩方式?
from subprocess import check_call
def gZipFile(fullFilePath)
check_call('gzip ' + fullFilePath)
谢谢!!
-
尝试这个:
check_call(['gzip', fullFilePath])
根据您对这些文件数据的处理方式,Skirmantas的http://docs.python.org/library/gzip.html链接也可能会有所帮助。请注意页面底部附近的示例。如果您不需要访问数据,或者您的Python代码中没有数据,则执行gzip可能是最干净的方法,因此您不必在Python中处理数据。