Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 8, 2019 22:11
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 parzibyte/fdac7b44314b76560c6cd18af1484a7a to your computer and use it in GitHub Desktop.
Save parzibyte/fdac7b44314b76560c6cd18af1484a7a to your computer and use it in GitHub Desktop.
"""
Escribir datos en un archivo con Python
Ejemplo 2: crear archivo y adjuntar contenido
https://parzibyte.me/blog
"""
nombre_archivo = "readme.txt"
with open(nombre_archivo, "a") as archivo:
archivo.write("Hola, escribiendo texto\n")
archivo.write("Cada que ejecutes el archivo, el texto se agrega al final\n")
archivo.write("parzibyte.me")
archivo.write("\n")
# No olvides cerrar el archivo
archivo.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment