filename=r'E:awifidictjikefeng.txt' file1=r'E:awifi1.txt' file2=r'E:awifi2.txt' # 把1.txt每一行进行对比,长度大于8则写到2.txt里 with open(filename,'r') as f1: with open(file2,'w') as f2: for l1 in f1: if len(l1)>8 : f2.write(l1) print(l1)