The read function reads the whole file at once. You can use the readlines function to read the file line by line. You can use the following to read the first line:
f = open('my_file.txt', 'r+') print(f.readline())
The read function reads the whole file at once. You can use the readlines function to read the file line by line. You can use the following to read the first line:
f = open('my_file.txt', 'r+') print(f.readline())