gzip a file in Python

后端 未结 7 2059
悲&欢浪女
悲&欢浪女 2020-12-28 12:47

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 ther

7条回答
  •  一生所求
    2020-12-28 13:09

    Try this:

    check_call(['gzip', fullFilePath])
    

    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.

提交回复
热议问题