谢谢你的再次回复。测试了,没有达到预定的效果,不知是哪里的问题?
下面是代码处理的全过程:
程序代码:
def check(n):
temp = int(n)//10+int(n)%10
if temp %2:
return '1'
else:
return '0'
def output(filename,content):
print(filename,content,'\n')
def output(filename,content):
f=open(filename,'w+')
for i in content:
f.write(','.join(i)+'\n')
f.write(data)
f.close()
f=open('data.txt','r+')
data=[i.strip().split(',') for i in f]
f.close()
index1=[tuple(map(lambda x:check1(x),i)) for i in data]
indexdict1=dict([[i,[]] for i in set(index1)])
for i,j in zip(data,index1):
indexdict1[j].append(i)
for i in indexdict1:
output(''.join(i)+'.txt',indexdict1[i])
[此贴子已经被作者于2021-3-26 22:30编辑过]