开发者

Python : updating values in a dictionary

开发者 https://www.devze.com 2022-12-20 18:08 出处:网络
I have the following dictionary -> key : (time,edge_list) Now I开发者_开发问答 want to increment all time values by 1. How do I do that?

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

精彩评论

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