41 lines
926 B
Python
41 lines
926 B
Python
# 输入目标列表
|
|
t = """K0819001X
|
|
K0819002X
|
|
K0819003X
|
|
K0819004X
|
|
K0819005X
|
|
K0819006X
|
|
K0820001X
|
|
K0820002X
|
|
K0820003X
|
|
"""
|
|
|
|
import json
|
|
with open("../题库0.3/Problems.json","r",encoding = "utf8") as f:
|
|
database = f.read()
|
|
pro_dict = json.loads(database)
|
|
|
|
dict1 = {}
|
|
for o in [l.strip() for l in t.split("\n") if len(l.strip())>0]:
|
|
dict1[o] = []
|
|
for id in pro_dict:
|
|
for o in dict1:
|
|
objs = pro_dict[id]["objs"]
|
|
flag = True
|
|
if not o in objs:
|
|
flag = False
|
|
for obj in objs:
|
|
if obj > o:
|
|
flag = False
|
|
break
|
|
if flag:
|
|
dict1[o].append(id)
|
|
output = ""
|
|
for o in dict1:
|
|
if not dict1[o] == []:
|
|
print('"'+o+'":"'+",".join(dict1[o])+'",')
|
|
output += '"'+o+'":"'+",".join(dict1[o])+'",'+"\n"
|
|
|
|
with open(r"临时文件\课时目标寻找题目结果.txt","w",encoding = "utf8") as f:
|
|
f.write(output)
|