Answer the question
In order to leave comments, you need to log in
How to open txt files in python program?
Hello!
Help me please. I am trying to figure out how to open files through Python. I tried the options that were suggested on the Internet, but they did not work. (for example)
f = open('text.txt')
f.read()
Explain me how open at least text files. I would be very grateful.
PS
I'm very sorry for the stupid questions, but, alas, I have nowhere else to turn. Thanks in advance!
Answer the question
In order to leave comments, you need to log in
What might not work here?
Move to the directory where the file is
with open("Sante-1.csv") as f:
r = f.read()
print(r)
f= open("/Users/leah/Documents/Sante-1.csv")
r = f.read()
print(r)
Perhaps the author expects the specified file to open in some text editor.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question