[python][库]gzip库使用方法
2017-09-15 10:30
302 查看
原文链接
解压gzip文件示例:
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()
相关文章推荐
- python的gzip库使用方法
- python~module gzip 使用方法,及简介! 附件 python ~ os 模块!!!
- python的gzip库使用方法
- python的gzip库使用方法
- python的gzip库使用方法
- python的gzip库使用方法
- tar、gzip、unzip命令的详细使用方法
- Python源代码中使用中文的方法
- 升级Python而导致的YUM服务无法使用的修复方法
- p4.pm p4python p4perl p4api 的使用方法
- tar、gzip、unzip命令的详细使用方法备忘
- python中datetime的比较方法使用
- 【原】Python/C API使用方法简介 (在C/C++中嵌入Python)
- Python strip lstrip rstrip使用方法(字符串处理空格)
- tar、gzip、unzip命令的详细使用方法备忘
- Python2.5使用新浪微博Python SDK遇到的问题与解决方法
- tar、gzip、unzip命令的详细使用方法备忘
- Python strip lstrip rstrip使用方法
- python 的方法不能使用中文
- 【用Python写爬虫】获取html的方法【四】:使用urllib下载文件