Open a text file and write a line of text : Text File Read Write « File « Python






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()

           
       








Related examples in the same category

1.Open a file and read a lineOpen a file and read a line