Python: files

##### OPEN, CLOSE AND OPEN/CLOSE WITH ‘with’:

f = open("salida.txt", "w")
for item in mi_lista:
    f.write(str(item) + "\n")
f.close()

mi_archivo = open("salida.txt", "r+")
with open("texto.txt", "w") as mi_archivo:
    mi_archivo.write("tu puta madre")
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s