how to discard a line if it's not a number?

dawenliu at gmail.com dawenliu at gmail.com
Sat Oct 29 16:29:27 EDT 2005


Hi, I'm reading a file line by line, and whenever a line is not
consisted of a single number (such as 0.315), I want to discard that
line (and store only the single numbers).

For example,

0.315
discarded this line of text
3.8
-1.44
forget about me also
2.6


Then I want to store only the four numbers into another file, without
the two sentences.  
Suggestions are appreciated!




More information about the Python-list mailing list