Python - how to open text file and read line by line
Hi,
how to cycle a text file in a python - I need to read the file and then iterate line by line and print the contents.
Hi,
here is one way to go through the python of the whole text file of the line after the line with the while loop:
how to cycle a text file in a python - I need to read the file and then iterate line by line and print the contents.
REPLY
Hi,
here is one way to go through the python of the whole text file of the line after the line with the while loop:
file = open("file.txt", "r")
while True:
line = file.readline()
if not line :
break;
print(line.strip())
file.close()