fichier de lecture python
with open("file.txt", "r") as txt_file:
return txt_file.readlines()
Supermavster
with open("file.txt", "r") as txt_file:
return txt_file.readlines()
txt = open('FILENAME.txt')
txtread = txt.read()
print(txtread)
print(txt.read())
l_a=[]
l_m=[]
l_w=[]
with open("spots.txt","r") as file:
line=file.readlines()
for i in range(0,len(line),1):
[a,m,w]=line[i].split()
l_a.append(float(a))
l_m.append(float(m))
l_w.append(float(w))
#there are many modes you can open files in. r means read.
file = open('C:\Users\yourname\files\file.txt','r')
text = file.read()
#you can write a string to it, too!
file = open('C:\Users\yourname\files\file.txt','w')
file.write('This is a typical string')
#don't forget to close it afterwards!
file.close()
with open('pagehead.section.htm','r') as f:
output = f.read()
# Open function to open the file "MyFile1.txt"
# (same directory) in append mode and
file1 = open("MyFile.txt","a")
# store its reference in the variable file1
# and "MyFile2.txt" in D:\Text in file2
file2 = open(r"D:\Text\MyFile2.txt","w+")