Cli*_*ley 1 python dictionary python-3.5
我有以下字典:
dic= {'I-setosa': 8, 'I-versicolor': 2, 'I-virginica': 0}
Run Code Online (Sandbox Code Playgroud)
如何找到密钥的总和?在Python 2我可以做到以下几点:
sum(dic.values())
Run Code Online (Sandbox Code Playgroud)
除此之外,还有其他方法吗?我尝试使用dic.values()并找到该列表的总和,但这太长了。