python比较文件中某些列的值
发布网友
发布时间:2022-04-18 21:19
我来回答
共1个回答
热心网友
时间:2022-04-18 22:48
import glob
import fileinput
import io
filelist=glob.glob('a.txt')
for x in filelist:
read = open(x,'r',encoding = 'utf-8')
line = read.readline()
while(line!=''):
a=line.replace('\n','').split(' ')
if a[1] == a[2]:
print(line)#写入文件在这里写
line = read.readline()
read.close()