You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
383 B

#1.txt为关键词
#2.txt为提取目标
#3.txt储存提取结果
f = open('1.txt','r',encoding='utf-8')
q = open('3.txt','a+',encoding='utf-8')
line1 = f.readlines()
for l in line1:
p = open('2.txt', 'r', encoding='utf-8')
line2 = p.readlines()
for ll in line2:
if l.strip() in ll:
q.writelines(ll)
p.close()
f.close()
q.close()