Page 1 of 1

Python: Reading a File without Auto-Closing

Posted: Wed Aug 20, 2025 12:12 pm
by The Jason

Code: Select all

school_students_dot_txt = open("school_students.txt")

print(school_students_dot_txt.readline())

school_students_dot_txt.close()

# Line had to be created to close the file.