Reputation: 21
I´m trying to read a .txt
file in Python. I have this code:
file = open("LESEN.txt","r")
print(file)
When I try to run it, this error comes up:
<built-in method read of _io.TextIOWrapper object at 0x0000024B969DA4D0>
I can remember that it works in a older Python version. What am I doing wrong?
Upvotes: 1
Views: 6693
Reputation: 1
f = open("INTERVIEW_SCHEDULES.txt","r") # You can remove r on the open(), it is read mode by default.
content = f.read()
print(content)
f.close()
Upvotes: 0
Reputation: 19242
There are two issues with your code:
file.read()
for that.Here is a code snippet that resolves both issues:
with open("LESEN.txt", "r") as file:
print(file.read())
Upvotes: 3