Difference between revisions of "Perform IO with Text Files"
Jump to navigation
Jump to search
(Created page with "==Opening a File== myfile= open('filename.txt') myfile.read() # reads a string of everything in the file myfile.seek(0) # reset the cursor to the top of the file contents...") |
(No difference)
|
Revision as of 22:54, 5 January 2019
Opening a File
myfile= open('filename.txt') myfile.read() # reads a string of everything in the file myfile.seek(0) # reset the cursor to the top of the file contents = myfile.read() myfile.readlines() # will read lines as a list myfile.close() # closes the file with open('filename.txt') as my_new_file: contents = my_new_file.read()
==File Locations==