This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: ) dataout.write(“Some text \ n”) dataout.write(“…that is written to a file \ n”) dataout.close() (See writing_file.py for explanation about the above statements.) • Test the code in Figure 7.3 in the Study Guide (Page 149) 3 Writing to files • We can also read data from an existing file: datain = file(“sample.txt”, “r”) (or: datain = open(“sample.txt”, “r”) ) data = datain.read() # read() returns entire file as a string print(data) datain.close() • Test the above code 4 Reading from files...
View Full Document
This note was uploaded on 08/28/2011 for the course CMPT 125 taught by Professor Diana during the Spring '08 term at Simon Fraser.
- Spring '08