Mega Code Archive

 
Categories / Python / File
 

Open a text file and write a line of text

myfile = open('myfile', 'w')             # open for output (creates) myfile.write('hello text file\n')        # write a line of text myfile.close()