Work with file Flashcards
1
Q
close
A
Close the file
2
Q
read
A
Read content of the file, can assign it to a variable or print it
3
Q
readline
A
Read first line of the file
4
Q
truncate
A
Empties the file
5
Q
write(“stuff”)
A
Write “stuff” to the file
6
Q
seek(0)
A
Moves the read/write location to beginning of the file.
7
Q
read(5)
A
read first 5 letters of the file
8
Q
open(filename, ‘r’)
A
open the file, read only, assign to a file object
9
Q
readlines()
A
Read all lines of the file, store as a list of string (each line)