From e7c9fd8aec66ea1d5ee7a4f4b2a10a9dcbd47a03 Mon Sep 17 00:00:00 2001 From: pg7s85mrc <3224571700@qq.com> Date: Wed, 18 Sep 2024 17:28:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 提取信息.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 提取信息.py 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() +