Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (16.4k points)

I've simply make extracts of gzip on python. 

import gzip

f=gzip.open('Onlyfinnaly.log.gz','rb')

file_content=f.read()

print file_content

What's more, I get no yield (output) on the screen. As an amateur of python, I'm considering how should I respond on the off chance that I need to peruse the substance of the document in the gzip record. Much thanks to you.

1 Answer

0 votes
by (26.4k points)

Take a stab at gzipping some information through the gzip library like this... 

import gzip

content = "Lots of content here"

f = gzip.open('Onlyfinnaly.log.gz', 'wb')

f.write(content)

f.close()

Then try to execute your code as posted..

import gzip

f=gzip.open('Onlyfinnaly.log.gz','rb')

file_content=f.read()

print file_content

This technique worked for me concerning some explanation the gzip library neglects to read a few records.

Want to become a expert in Python? Join the python course fast!

For more details, do check out the below video tutorial...

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
2 answers
0 votes
1 answer

Browse Categories

...