python的gzip库使用方法
2014-04-24 17:30
295 查看
解压gzip文件示例:
创建gzip文件:
gzip压缩现有文件:
更多内容请见:
https://docs.python.org/2/library/gzip.html
import gzip f = gzip.open('file.txt.gz', 'rb') file_content = f.read() f.close()
创建gzip文件:
import gzip content = "Lots of content here" f = gzip.open('file.txt.gz', 'wb') f.write(content) f.close()
gzip压缩现有文件:
import gzip f_in = open('file.txt', 'rb') f_out = gzip.open('file.txt.gz', 'wb') f_out.writelines(f_in) f_out.close() f_in.close()
更多内容请见:
https://docs.python.org/2/library/gzip.html
相关文章推荐
- python的gzip库使用方法
- python的gzip库使用方法
- [python][库]gzip库使用方法
- python的gzip库使用方法
- python~module gzip 使用方法,及简介! 附件 python ~ os 模块!!!
- python的gzip库使用方法
- 如何高效使用Python字典的方法详解
- python中OrderedDict的使用方法详解
- python中getattr函数使用方法 getattr实现工厂模式
- 【再回首Python之美】【类-三种方法】绑定方法、@staticmethod、@classmethod的基本使用
- gzip,bzip2,tar,zip命令使用方法详解
- 在Linux命令行终端中使用python的简单方法(推荐)
- Python strip lstrip rstrip使用方法(字符串处理空格)
- 在 Python 应用中使用 MongoDB的方法
- python使用discover方法遍历所有要执行的用例
- python之split()使用方法
- Python 中的 map, reduce, zip, filter, lambda基本使用方法
- Python的hasattr() getattr() setattr() 函数使用方法
- python中defaultdict方法的使用
- Python中isnumeric()方法的使用简介