I'm trying to open a txt file in python, but I'm having trouble. It seems to be working, but I cannot get the text anywhere. Here is the code, does anyone know how I can get the text from the hello.txt file?

f = open("c:/users/verzo/desktop/hello.txt")
print(f)

Use the read method.

commented: Ah, works perfectly. Thanks! +0

In other words ...

f = open("c:/users/verzo/desktop/hello.txt")
text = f.read()
print(text)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.