How to get rid the new line

Markus von Ehr markus.vonehr at ipm.fhg.de
Thu Jun 27 05:04:52 EDT 2002


        f = open(filename, 'r')
        lines = f.readlines()
        line1 = lines[0] # exemplarily for first line
        line1 = line1[0:len(line1)-1]

or:
        f = open(filename, 'r')
        lines = f.readlines()
        line1 = lines[0][0:len(line1)-1] # exemplarily for first line

Markus

SiverFish schrieb:

> 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 )




More information about the Python-list mailing list