Unit 15 Flashcards
15.1 - Reading Files
What does open()
do?
retrieves input based on a file
15.1 - Reading Files
What is the difference between xfile.read()
and xfile.readlines()
?
.read
returns ALL file contents into a string.readlines
returns a list with each element as a line from the text
15.2 - Writing Files
What does xfile.write()
do?
writes a string argument to a file
use \n
to actually write it to the file
15.2 - Writing Files
What are the three modes for editing a file?
r = reading
w = write (over)
a = append
15.3 - Interacting with File Systems
What is portability?
the ability to access an item easily from multiple locations
15.4 - Binary Data
What is binary data?
data stored in a sequence of bytes
15.4 - Binary Data
What is a bytes object?
a sequence of single byte values
15.5 - The “With” Statements
What is a with statement?
a function-like series of code that occurs while a file is opened; automatically closes once completed