CS116 Chapter Notes - Chapter 9: Decimal Mark, Empty String, Newline

81 views7 pages

Document Summary

Cannot read from a file being written to. Cannot write to a file being read from. Easiest: ensure that the file being accessed is in the same folder as the program using it (active folder, directory) Guard the file action by placing it inside a try-except block. If an error occurs in the try block, the code in the except block is executed immediately. If no errors, then the code in the except block is not executed. Any error in the try block will cause the except block code to be executed immediately. Be sure that the steps in the except block are suitable for all errors in the try block. Do not use try-except until you have debugged the code in the try block for other, avoidable errors. Do not use try-except as an alternative to an if statement. Returns the empty string when at end of file. Returns a list of strings containing each line from file f.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers