Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created July 4, 2018 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/8b65b5ca74509bb764e0c83ba6856195 to your computer and use it in GitHub Desktop.
Save Fhernd/8b65b5ca74509bb764e0c83ba6856195 to your computer and use it in GitHub Desktop.
Manipulación de cadenas de caracteres con representaciones textuales y binarias. OrtizOL.
from io import StringIO, BytesIO
# StringIO diseñada para la manipulación de texto:
cadena = StringIO()
cadena.write('¡Python es génial!\n')
print('Python is awesome!', file=cadena)
print(cadena.getvalue())
# BytesIO diseñada para trabajar a nivel de bytes:
cadena = BytesIO()
cadena.write(b'Python es un lenguaje muy expresivo.')
print(cadena.getvalue())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment