python脚本如何删除其中一列含特殊值的特定行,如例子中第4列为0.00的第2、4行

原数据in.txt
1119 128363 128 383.00
1120 128364 128 0.00
1121 132225 132 335.00
1127 131642 128 0.00
1122 132226 132 331.00
期望结果,输出文本out.txt:
1119 128363 128 383.00
1121 132225 132 335.00
1122 132226 132 331.00

f=open("in.txt", "r")
fw = open("out.txt", "w")
datas = f.readlines()
for data in datas:
    d = data.split()
    if d[3] != '0.00':
        f.write(data)
f.close()
fw.close()

温馨提示:答案为网友推荐,仅供参考
相似回答