Mega Code Archive

 
Categories / Python / File
 

Demonstrates writing to a text file

#  print "Creating a text file with the write() method." text_file = open("write_it.txt", "w") text_file.write("Line 1\n") text_file.write("This is line 2\n") text_file.write("That makes this line 3\n") text_file.close()