丰富database_tools
This commit is contained in:
parent
45959491a0
commit
6150a750c5
|
|
@ -491,5 +491,17 @@ def parseUsage(usagestring): #对单行usage信息进行分词
|
|||
usagedict["glossdiff"] = round(sum(usagedict["difficulties"])/usagedict["subproblems"],3)
|
||||
return usagedict #返回词典, 含date日期, classid班级标识, subproblems小题数目, difficulties得分率, glossdiff小题平均得分率
|
||||
|
||||
def StringSubstibute(regex,template,stringtuple): # 用stringtuple里的字符串逐个替换template中的符合某种regex规则的字符串
|
||||
toSub = re.findall(regex,template)
|
||||
if not len(toSub) == len(stringtuple):
|
||||
print("长度不符.")
|
||||
return 1 #若长度不符则显示“长度不符”并返回1
|
||||
else:
|
||||
output = template
|
||||
for i in range(len(toSub)):
|
||||
output = re.sub(toSub[i],stringtuple[i],output)
|
||||
return output #若长度符合则返回替换后的字符串
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("数据库工具, import用.")
|
||||
Reference in New Issue