Computer Science 1026A/B Lecture Notes - Lecture 7: File Descriptor, Lineo, Empty String

122 views6 pages
terubarenuka and 39895 others unlocked
COMPSCI 1026A/B Full Course Notes
26
COMPSCI 1026A/B Full Course Notes
Verified Note
26 documents

Document Summary

When opening a le for reading, the le must exist (and otherwise be accessible) or an exception occurs. If writing the le must close it. Line = in le. readline() : read the just rst line. Read the whole le, can use while loop. \n : go to the next line. Suppose you are given a text le that contains a sequence of oating point value, stored one value per line. You need to read the value and write them to a new output le, aligned in a column and followed by their total and average value. If the input le has the contents. For line in inputfile: line = line. resplit() e. x. After opening the le you want to write to, there are two ways to trite to the le. Result = inputstring. rsplit ( , 1): means only split once.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions