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")

Recommended Answers

Use the read method.

Jump to Post

All 2 Replies

Use the read method.

commented: Ah, works perfectly. Thanks! +0

In other words ...

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

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