database_tools中添加根据字符串返回班级列表共嫩

This commit is contained in:
wangweiye7840 2024-03-27 13:26:49 +08:00
parent 96b12525b3
commit 0300d5e884
1 changed files with 17 additions and 0 deletions

View File

@ -173,6 +173,23 @@ def generate_number_set(string,*thedict): #根据可能含有":"和","的题号
else:
return "输入参数有误"
def generate_classid(string): #返回班级列表
string = re.sub(r"[\n\s]","",string).strip()
while not string[-1] in "0123456789":
string = string[:-1]
string = RefinePunctuations(string)
string_list = string.split(",")
numbers_list = []
for s in string_list:
if not ":" in s:
numbers_list.append(s.zfill(2)+"")
else:
start,end = s.split(":")
for ind in range(int(start),int(end)+1):
numbers_list.append(str(ind).zfill(2)+"")
return numbers_list #返回2位班级号列表
def generate_id_set(string,*thedict): #除了生成题号列表外, 还能根据首字母生成基础知识编号列表或课时目标列表
if re.findall(r"[BXK]",string) == []:
if thedict == ():