Files
Creating file object
- Syntax: file_object = open(filename, mode)
- input = open(“d:\inventory.dat”, “r”)
- output = open(“d:\report.dat”, “w”)
Manual close
- Syntax: close(file_object)
Reading an entire file
- Syntax: string = file_object.read()
- Syntax: list_of_strings = file_object.readlines()
- lines = input.readlines()