python-如何为gzip压缩的base64d字符串充气 [英] python - how to inflate gzipped, base64d string
本文介绍了python-如何为gzip压缩的base64d字符串充气的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是想知道如何对文本字符串进行充气/解压缩,而该文本字符串也是具有base64编码的压缩压缩字符串?
I'm just wondering how is it possible to inflate/decompress a string of text that is a gzipped compressed string that also hase base64 encoding?
例如,所有python示例似乎都集中在打开文件上,而我想处理压缩后的字符串.
For instance, all the python examples seem to focus on opening a file, whereas I want to work on a gzipped string.
推荐答案
您可以使用base64和zlib库:
You can use base64 and zlib libraries:
import base64, zlib
decoded_data = zlib.decompress(base64.b64decode(encoded_data))
gzip模块仅用于文件操作: https://docs.python. org/2/library/gzip.html . 它使用zlib进行实际的压缩/解压缩.
The gzip module is only for file operations: https://docs.python.org/2/library/gzip.html. It uses zlib for actual compression/decompression.
这篇关于python-如何为gzip压缩的base64d字符串充气的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文