data?=?[['张三',?4],?['张三',?5],?['李四',?3],?['李四',?2],?['王五',?1]]
arr1?=?set([k?for?k,?v?in?data])?#?姓名去重?得到:?{'王五',?'李四',?'张三'}
arr2?=?[]?#?设置一个空数组
for?user?in?set(arr1):?#?遍历去重后的数组?和?原数组对比?累加姓名相同的值
arr2.append([user,sum([n?for?u,?n?in?data?if?u?==?user])])?#?添加到arr2数组
print(arr2)?#?输出结果:[['张三',?9],?['李四',?5],?['王五',?1]]