Python unzipping stream of bytes?

前端 未结 4 720
时光取名叫无心
时光取名叫无心 2020-11-27 15:34

Here is the situation:

  • I get gzipped xml documents from Amazon S3

    import boto
    from boto.s3.connection import S3Connection
    from boto.s3.key i         
    
    
            
4条回答
  •  臣服心动
    2020-11-27 16:21

    I had to do the same thing and this is how I did it:

    import gzip
    f = StringIO.StringIO()
    k.get_file(f)
    f.seek(0) #This is crucial
    gzf = gzip.GzipFile(fileobj=f)
    file_content = gzf.read()
    

提交回复
热议问题