From c8499d4199c7ed583fa081ca8a86c401fe4ea78c Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Sun, 1 Oct 2023 00:00:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BB=8E=E9=A2=98=E5=BA=93?= =?UTF-8?q?=E4=B8=AD=E9=80=89=E6=8B=A9=E6=8C=87=E5=AE=9A=E5=B9=B4=E7=BA=A7?= =?UTF-8?q?=E5=8A=9F=E8=83=BDselect=5Fgrade=5Ffrom=5Fpro=5Fdict?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/database_tools.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/工具v2/database_tools.py b/工具v2/database_tools.py index 3a24ccb8..3e9bcc09 100644 --- a/工具v2/database_tools.py +++ b/工具v2/database_tools.py @@ -1234,5 +1234,29 @@ def SubstringOccurence(regex,string): #生成regex在string中出现的所有位 poslist = [item.start() for item in re.finditer(regex,string)] return poslist +def select_grade_from_pro_dict(prodict,grades): + if len(grades) == 0: + return prodict + else: + gradelist = [] + for g in grades: + if not "届" in g: + gradelist.append(g+"届") + else: + gradelist.append(g) + adict = prodict.copy() + for id in prodict: + raw_usages = prodict[id]["usages"].copy() + new_usages = [] + for u in raw_usages: + for g in gradelist: + if g in u: + new_usages.append(u) + adict[id]["usages"] = new_usages.copy() + return adict + + + + if __name__ == "__main__": print("数据库工具, import用.") \ No newline at end of file