The below code snippet demonstrates how to open a file, read line by line and auto close the file:
with open('file.txt') as the_file:
for line in the_file:
print(line.rstrip())
Experiences of a DBA
The below code snippet demonstrates how to open a file, read line by line and auto close the file:
with open('file.txt') as the_file:
for line in the_file:
print(line.rstrip())