Created
August 8, 2019 22:17
-
-
Save parzibyte/08c50c21450875177cccceb989101188 to your computer and use it in GitHub Desktop.
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
""" | |
Escribir datos en un archivo con Python | |
Ejemplo 3: excepciones | |
https://parzibyte.me/blog | |
""" | |
nombre_archivo = "." | |
try: | |
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() | |
except Exception as e: | |
print("Error abriendo archivo:", e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment