【发布时间】:2014-04-10 15:55:30
【问题描述】:
如何将{'CS2261': '140', 'CS3264': '55'} 转换为{'CS2261': 140, 'CS3264': 55}?
def everything(file):
a = {}
with open(file, 'r') as f:
for i in f:
Module,Group,Quota = i.split(',')
if Module not in a:
a[Module] = int(Quota)
return a
【问题讨论】:
-
您正在询问转换 字典,但随后发布了构建 字典的代码示例。
everything()函数的确切问题是什么,它与第一句话的关系是什么?
标签: python dictionary int