Created
July 6, 2018 13:30
-
-
Save Fhernd/6d2eb21d05c2669348be419a6a1bab82 to your computer and use it in GitHub Desktop.
Compresión y decompresión de archivos de datos. OrtizOL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gzip | |
import bz2 | |
# Descompresión: | |
with gzip.open('fibonaccis-2.tar.gz', 'rt') as f: | |
contenido = f.read() | |
print (contenido) | |
with bz2.open('fibonaccis-2.tar.bz2', 'rt') as f: | |
contenido = f.read() | |
print(contenido) | |
# Compresión: | |
with gzip.open('fibonaccis-2.bz', 'wt') as f: | |
f.write('Python es amazing!') | |
with bz2.open('fibonaccis-2.bz2', 'wt') as f: | |
f.write('Python es tremendo!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment