#!/usr/local/python
# -*- coding:utf-8 -*-user_dict = {'python': 23, 'Python': 51, '机器':10, 'PYTHON': 12, '机器人': 14, 'py':8, 'Py':9}

req_dict, tmp_dict = {}, {}
# init a dict that value is a list to collect the value that belong to the same req tag
for k in user_dict.keys():
tmp_dict.setdefault(k.lower(), [])

for k, v in tmp_dict.items():
for kk, vv in user_dict.items():
if k == kk.lower():
v.append(vv)
req_dict[k] = sum(v)
print(tmp_dict, req_dict)
 output:{'python': [23, 51, 12], '机器': [10], '机器人': [14], 'py': [8, 9]} {'python': 86, '机器': 10, '机器人': 14, 'py': 17}

相关文章:

  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-18
  • 2021-09-30
  • 2022-01-26
  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案