Jak odczytać plik w 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()
f=open("Diabetes.txt",'r')
f.read()
#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()
my_file = open("C:\\Users\\Python\\file.txt", "r")
#Give the path accurately and use \\
text = my_file.read()
print(text)
#Output: The text in file.txt will be printed
spv = open("example.txt", "r")
print(spv.red())
# r, is to make the file readable but you can have more like: a - w - x - t - b