a = file.readline() b = # save the position (line) read from the file while a != "TEST": a = file.readline c = # continue reading the file from the position b
??




Posted 28 April 2012 - 12:06 PM
try:
#First of all, let's open the file
file = open('file_name.txt')
#Create a sequence, where we can write down all line from the file
each_lines = []
#Iterate the file and write down each line
for each_line in file:
each_lines.append(each_line)
#Now, you can do all you want to do with each line...
except IOError:
print('This is a problem with your file')
import os
if os.path.exists('file_name.txt'):
#First of all, let's open the file
file = open('file_name.txt')
#Create a sequence, where we can write down all line from the file
each_lines = []
#Iterate the file and write down each line
for each_line in file:
each_lines.append(each_line)
#Now, you can do all you want to do with each line...
else:
print('Your file isn\'t exist')
This post has been edited by Faitas: 28 April 2012 - 12:09 PM
Posted 28 April 2012 - 02:28 PM
Faitas, on 28 April 2012 - 12:06 PM, said:
try:
#First of all, let's open the file
file = open('file_name.txt')
#Create a sequence, where we can write down all line from the file
each_lines = []
#Iterate the file and write down each line
for each_line in file:
each_lines.append(each_line)
#Now, you can do all you want to do with each line...
except IOError:
print('This is a problem with your file')
import os
if os.path.exists('file_name.txt'):
#First of all, let's open the file
file = open('file_name.txt')
#Create a sequence, where we can write down all line from the file
each_lines = []
#Iterate the file and write down each line
for each_line in file:
each_lines.append(each_line)
#Now, you can do all you want to do with each line...
else:
print('Your file isn\'t exist')
