diff --git a/提取信息.py b/提取信息.py new file mode 100644 index 0000000..b498d1d --- /dev/null +++ b/提取信息.py @@ -0,0 +1,16 @@ +#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() +