commands of files Flashcards
1
Q
target = open(filename, ‘w’)
A
This is the way of opening files
we assign them to variables .
And the “open” command holds two values inside: the name of the file, and the mode in which file will be opened
2
Q
target.close()
A
It closes the file
3
Q
target.write(“something”)
A
This command writes in the file
4
Q
target.truncate()
A
Deletes what’s inside the file
5
Q
print(target.read())
A
We print what’s inside the file
6
Q
w+, r+, a+
A
Modifier allows you to open python in both read and write mode
7
Q
from os.path import exists
{exists(name_of_file)}
A
This is imported function that’s used to show «True» if file exists or false if doesn’t