CENG240-2021 Week11 File Handling
CENG240-2021 Week11 File Handling
File Handling
Disclaimer: Figures without reference are from either from “Introduction to programming concepts
with case studies in Python” or “Programming with Python for Engineers”, which are both co-authored
by me.
This Week
METU Computer Engineering
¢ File Handling
§ Files and sequential access
§ Parsing
§ Termination of input
§ Formatting files
§ Binary files
fp.close()
¢ Opening files:
§ open(filename, “r”) => open file for reading
§ open(filename, “w”) => open file for writing
§ open(filename, “a”) => open file for appending
¢ Closing file:
§ fileobject.close()