python recall a line from a text file code example
Example: python recall a line from a text file
# Read text file line by line
filepath = 'text_file.txt'
with open(filepath) as fp:
line = fp.readline()
cnt = 1
while line:
print("Line {}: {}".format(cnt, line.strip()))
line = fp.readline()
cnt += 1