问题描述
我想用 Python 压缩一个文件.我正在尝试使用 subprocss.check_call(),但它一直失败并出现错误OSError:[Errno 2] No such file or directory".我在这里尝试的有问题吗?有没有比使用 subprocess.check_call 更好的压缩文件的方法?
I want to gzip a file in Python. I am trying to use the subprocss.check_call(), but it keeps failing with the error 'OSError: [Errno 2] No such file or directory'. Is there a problem with what I am trying here? Is there a better way to gzip a file than using subprocess.check_call?
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 中处理数据.
Depending on what you're doing with the data of these files, Skirmantas's link to http://docs.python.org/library/gzip.html may also be helpful. Note the examples near the bottom of the page. If you aren't needing to access the data, or don't have the data already in your Python code, executing gzip may be the cleanest way to do it so you don't have to handle the data in Python.
这篇关于在 Python 中 gzip 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)