Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- """
- Resumen de help(open)
- ========================================================================
- Character Meaning
- ------------------------------------------------------------------------
- 'r' open for reading (default)
- 'w' open for writing, truncating the file first
- 'x' create a new file and open it for writing
- 'a' open for writing, appending to the end of the file if it exists
- 'b' binary mode
- 't' text mode (default)
- '+' open a disk file for updating (reading and writing)
- 'U' universal newline mode (deprecated)
- ========================================================================
- """
- # Creo un archivo y le guardo datos
- f = open("archivo.txt","x")
- # Escribo en el archivo y lo cierro
- f.write("Hola mundo\n")
- f.close()
- # Abro el archivo en modo lectura, imprimo los datos y lo cierro
- f = open("archivo.txt")
- print(f.read())
- f.close()
- # Abro el archivo para agregarle una línea:
- f = open("archivo.txt","a")
- f.write("Chau mundo\n")
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement