Let's say that we want to read a file named "versedog.txt" from the current folder (Python always has a current folder -- it's the same story as when we had to import modules.) Here is how we can do it:
f = open("versedog.txt", encoding="latin1")
(To make this work, place your .py file in the same folder as the file that you want to read, and use "Run file as script" in Pyzo).
We specify encoding="latin1" to make Python interpret all characters in versedog.txt as English letters. This will avoid all sorts of problems with file encodings. Of course, if the file is not actually written in the Lating alphabet, we'd be in big trouble!
To get the text of the file, we can now use
s = f.read()
s is now a string:
s
We can print the string, and have all the "\n" interepreted as newlines:
print(s)
Finally, let's introduce Pythons str.split() function. s.split(sep) splits the string s into a list of strings which in s are separated by the string sep. For example:
s.split("\n")
We can get line 11 in the file using
s.split("\n")[11]