优化:天赋的数字类型判断

This commit is contained in:
KimgiaiiWuyi 2022-06-25 01:25:50 +08:00
parent 2df9eef519
commit c11d79e672

View File

@ -664,27 +664,29 @@ async def char_wiki(name, mode='char', level=None):
labels = ''.join(data['attributes']['labels']) labels = ''.join(data['attributes']['labels'])
parameters_label = re.findall(r'{[a-zA-Z0-9]+:[a-zA-Z0-9]+}', labels) parameters_label = re.findall(r'{[a-zA-Z0-9]+:[a-zA-Z0-9]+}', labels)
labels = [] labels = {}
for i in parameters_label: for i in parameters_label:
i = i.replace('{', '').replace('}', '').split(':')[-1] value_type = i.replace('{', '').replace('}', '').split(':')[-1]
labels.append(i) value_index = i.replace('{', '').replace('}', '').split(':')[0]
labels[value_index] = value_type
for i in data['attributes']['parameters']: for para in data['attributes']['parameters']:
for index, j in enumerate(data['attributes']['parameters'][i]): if para in labels:
label_str = labels[para]
for index, j in enumerate(data['attributes']['parameters'][para]):
if add_switch: if add_switch:
parameters.append({}) parameters.append({})
label_str = labels[int(i.replace('param', '')) - 1]
if label_str == 'F1P': if label_str == 'F1P':
parameters[index].update({i: '%.2f%%' % (j * 100)}) parameters[index].update({para: '%.2f%%' % (j * 100)})
if label_str == 'F2P': if label_str == 'F2P':
parameters[index].update({i: '%.1f%%' % (j * 100)}) parameters[index].update({para: '%.1f%%' % (j * 100)})
elif label_str == 'F1': elif label_str == 'F1':
parameters[index].update({i: '%.1f' % j}) parameters[index].update({para: '%.1f' % j})
elif label_str == 'P': elif label_str == 'P':
parameters[index].update({i: str(round(j * 100)) + '%'}) parameters[index].update({para: str(round(j * 100)) + '%'})
elif label_str == 'I': elif label_str == 'I':
parameters[index].update({i: '%.2f' % j}) parameters[index].update({para: '%.2f' % j})
add_switch = False add_switch = False
for k in data['attributes']['labels']: for k in data['attributes']['labels']: