Class Notes (835,581)
Canada (509,259)
CP104 (46)
Lecture

nov7.docx

2 Pages
234 Views
Unlock Document

Department
Computer Science
Course
CP104
Professor
Ang�le Hamel
Semester
Fall

Description
07/11/12 Files Reading from a file File handle Def file_read(travel_file): #move to the beginning of the file travel_file.seek(0) for line in travel_file …process each line… Return… Template for a for loop In the main program File_name = input(‘Enter the file name’).strip() Travel_file = open(file_name,’r’,encoding=’utf-8’) Travel_contents= file_read(travel_file) Travel_file.close() OPEN AND CLOSE IN THE SAME PLACE (FN, MAIN PGM) Def file_read(trave_file) Travel_file.seek(0) Line = travel_file.readline() While line != “ ”: …process each line…
More Less

Related notes for CP104

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit