python如何解压gzip
解压gzip文件:
import gzip f = gzip.open('file.txt.gz', 'rb') file_content = f.read() f.close()1234
创建gzip文件:
import gzip content = "Lots of content here"f = gzip.open('file.txt.gz', 'wb') f.write(content) f.close()12345
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教程,尽在云海天教程网,欢迎在线学习!
来源:PY学习网:原文地址:https://www.py.cn/article.html