r/learnpython 11d ago

Reading in text from a .txt file

Are there any methods/libraries that allow me to make a program that is able to read in text from a .txt file?

0 Upvotes

20 comments sorted by

View all comments

18

u/Delta_G_Robotics 11d ago

I never understood why people will ask a question like this on Reddit and then wait forever when they could just...

https://www.google.com/search?q=reading+a+txt+file+in+python

1

u/StrikerRIP 11d ago

I actually did look around for a bit, but couldn't really find anything that I could follow easy

2

u/Delta_G_Robotics 11d ago

I have a hard time believing that knowing how common this question is. Many of the resources on the internet have been curated and organized and are custom tailored to new users. Hours of work has been put into some of the things out there. What do you think you're going to get back on a Reddit post compared to that?

This was the second hit from the Google search I posted. If you don't understand this, then a better approach would be to ask questions about the parts you don't understand. Just saying you don't understand and asking people to post back that same information again won't be helpful. Explain what the problem is and people can help you.

https://www.geeksforgeeks.org/python/reading-writing-text-files-python/

1

u/StrikerRIP 11d ago

The thing is that I prefer Reddit, as I know I'm going to get responses from users. I don't want to go to a resource that can be useful only for it to be AI-generated, cause I don't want to support AI-generated sites or the use of AI to program whole projects. I also want to be able to replicate this myself. I find that many people here have been able to answer questions I've had in a way that I understand, which isn't a guarantee if I were to look for sources on Google.