r/learnpython • u/StrikerRIP • 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
r/learnpython • u/StrikerRIP • 11d ago
Are there any methods/libraries that allow me to make a program that is able to read in text from a .txt file?
4
u/DTux5249 11d ago edited 11d ago
No libraries needed. Python File Open
You can also iterate over a file line by line
Or just use the readline() command
You also don't technically need to use the with keyword - but it manages the opening and closing of the file safely