files Flashcards
1
Q
in the terminal, get the path of file
A
pwd
2
Q
return the directories and file
A
ls
3
Q
return the directories and file with details
A
ls -la
4
Q
muoversi da una directory all’altra
A
cd
5
Q
open a file to a variable xxx
A
xxx=open(‘path’)
6
Q
close a stream of a file linked to variable xxx (2 metodi)
A
xxx.close()
with open('path') as xxx: ........
7
Q
iterate over lines (variable called xxx)
A
xxx=open(‘path’)
for line in xxx:
print(line)
8
Q
create list with single characters of a string as elements
A
lines=[] xxx=open('path') for line in xxx: lines+= line print(lines)
9
Q
create list with single lines of a string as elements
A
lines=[] xxx=open('path') for line in xxx: lines.append(line.strip()) print(lines)
10
Q
togliere spazi ed EOF da string
A
variablexxx.strip()
11
Q
fare lista con le singole parole di una string
A
variablexxx.split()
12
Q
read a tot number of characters
A
variablexxx.read (numberofcharachters)