GZip Module_Problem

I am writing a basic program to compress data from text_file,but it gave an error

import gzip

with gzip.open('gzip.txt','rb') as f:
    power_ = f.read()

print(power_)
Traceback (most recent call last):
  File "c:/Users/Nikhil/Desktop/file_sys_pr/gzip_module.py", line 11, in <module>
    power_ = f.read()
  File "C:\Users\Nikhil\AppData\Local\Programs\Python\Python37-32\lib\gzip.py", line 276, in read
    return self._buffer.read(size)
  File "C:\Users\Nikhil\AppData\Local\Programs\Python\Python37-32\lib\gzip.py", line 463, in read
    if not self._read_gzip_header():
  File "C:\Users\Nikhil\AppData\Local\Programs\Python\Python37-32\lib\gzip.py", line 411, in _read_gzip_header
    raise OSError('Not a gzipped file (%r)' % magic)
OSError: Not a gzipped file (b'po')

Encountered this error

I never did something with zip, but shouldn’t it be like this?

with open('gzip.txt','rb') as f:
    power_ = f.read()

You read the file as text.
And then in a second step, yout write that text (power_) in a zipped file

What you told is zip() which is a generator,but I was asking about GZip which is a module used to compress files such as videos,images into bytes.And GZip reads files in binary so it should be rb which is ‘read binary’.

But my question was I was getting an OSError,how to resolve it.