📚 › Python: the friendliest first language
12. Reading and writing files
Este artículo se traducirá automáticamente. Por ahora se muestra en inglés.
open() opens a file. Use with open(...) as f so the file closes automatically. f.write() writes text, and f.read() reads the whole file.
Use "w" to write (replacing the file), "a" to add to the end, and "r" to read.
Ver ejemplo
with open("notes.txt", "w") as f:
f.write("Hello file")
✍️ Ahora te toca
Make a list words holding Hi and Python, then print them joined with one space.