Python tiene la capacidad de poder abrir y editar archivos que sean de texto solamente. Como son los formatos .txt y .csv. Estos solo tienen valores, y no tienen ningún código binario de formato como lo tienen los archivos .doc o .docx de Microsoft Word.
La sintaxis de este comando es extremadamente facil.
Por ejemplo, para poder asignar el texto de un archivo a una variable se utiliza este comando: f=open(«archivo.txt»).
Lo que hace esto es asignar a «f» el texto del archivo.
Pero tambien con Python podemos escribir en un archivo de texto…
file = open(«newfile.txt», «w»)
file.write(«hello world in the new file»)
file.write(» and another line»)
file.close()
En este caso en el archivo newfile.txt, vamos a escribir «hello world in the new file and another line»
http://opentechschool.github.io/python-data-intro/core/text-files.html