How to get rid the new line
Oleg Broytmann
phd at phd.pp.ru
Thu Jun 27 04:47:21 EDT 2002
On Thu, Jun 27, 2002 at 06:34:27PM +0000, SiverFish wrote:
> Anyone tell me how to skip the empty line when you read through the file
> and copy the information in to the list(no empty line )
It depends on how you have opened the file - in text or binary mode. In
text mode it is simple:
infile = open(filename, 'r')
for line in file: # require python 2.2
if line != '\n': # end-of-line in the beginning of the line - the line is empty
process(line)
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-list
mailing list