如文件(t.txt)中有数据:
1.2332 2.3232 3.433434 5.4343
2.3232 5.4343 9.3232
912.21 111 123.123
1 f = open('t.txt') 2 3 rs = [] 4 5 [rs.extend(x.strip().split()) for x in f] 6 rs = [x for x in rs if float(x) > 5] 7 print rs 8 9 10 11 12 """ 13 for x in f: 14 rs.extend(x.strip().split()) 15 16 rs = [float(x) for x in rs] 17 rs = [x for x in rs if x > 5] 18 print rs 19 """