开发者

Python : updating values in a dictionary

I have the following dictionary ->

key : (time,edge_list)

Now I开发者_开发问答 want to increment all time values by 1. How do I do that?

dict_list = dict(key:(time+1,edge_list) for key:(time,edge_list) in dict_list)


>>> d={"key" : (100,"edge_list")}
>>> for i,(time,edge_list) in d.items():
...  d[i] = time+1, edge_list
... 
>>> d
{'key': (101, 'edge_list')}


dict((key, (time + 1, edge_list)) for (key, (time, edge_list)) in somedict.iteritems())
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜