MIS 304 Lecture Notes - Lecture 11: Newline
Document Summary
Output file: a file that data is written to. Input file: a file from which data is read. 3 steps that must be taken when a file is used by a program. Opening in a different location: file_variable = open(r"path", mode) Reading entire contents of a file: variable = file_variable. read() Reading a single line of file: variable = file_variable. readline() File cannot be changed or written to. Numbers must be converted to strings before they can be written to a file. Creates file if it does not exist. Appends data to end if it does. Prevents loss of data because it forces data in the buffer to be written to the file. Text file: contains data that has been encoded as text. Binary file: contains data that has not been converted to text. Sequential access file: access data from the beginning to end of the file.