30 lines
1017 B
Python
30 lines
1017 B
Python
import os,re,json
|
|
"""这里编辑题号(列表)后将在vscode中打开窗口, 编辑后保存关闭, 随后运行第二个代码块"""
|
|
problems = "2693,3670"
|
|
|
|
def generate_number_set(string,dict):
|
|
string = re.sub(r"[\n\s]","",string)
|
|
string_list = string.split(",")
|
|
numbers_list = []
|
|
for s in string_list:
|
|
if not ":" in s:
|
|
numbers_list.append(s.zfill(6))
|
|
else:
|
|
start,end = s.split(":")
|
|
for ind in range(int(start),int(end)+1):
|
|
numbers_list.append(str(ind).zfill(6))
|
|
return numbers_list
|
|
|
|
with open(r"../题库0.3/Problems.json","r",encoding = "utf8") as f:
|
|
database = f.read()
|
|
pro_dict = json.loads(database)
|
|
|
|
idlist = generate_number_set(problems,pro_dict)
|
|
|
|
output_list = {}
|
|
for id in idlist:
|
|
output_list[id] = pro_dict[id].copy()
|
|
|
|
with open(r"临时文件/problem_edit.json","w",encoding="u8") as f:
|
|
f.write(json.dumps(output_list,indent = 4,ensure_ascii=False))
|
|
os.system(r"code -g 临时文件/problem_edit.json") |