string = input("Please enter the text you want to compress")
file = input("Please enter the desired filename")
with gzip.open(file+".gz","wb") as f_out:
f_out.write(string)
Le code python ci-dessus me donne l'erreur suivante:
Traceback (most recent call last):
File "C:/Users/Ankur Gupta/Desktop/Python_works/gzip_work1.py", line 33, in <module>
compress_string()
File "C:/Users/Ankur Gupta/Desktop/Python_works/gzip_work1.py", line 15, in compress_string
f_out.write(string)
File "C:\Python32\lib\gzip.py", line 312, in write
self.crc = zlib.crc32(data, self.crc) & 0xffffffff
TypeError: 'str' does not support the buffer interface