Files Flashcards
1
Q
Working with data files
A
• In Python, we must open files before we can use them and close them when we are done with them.
2
Q
Open & close
A
open(filename, ‘r’)
Open a file called filename and use it for reading. This will return a reference to a file object.
open(filename, ‘w’)
Open a file called filename and use it for writing. This will also return a reference to a file object.
filevariable.close() File use is complete.