我有這樣的嵌套dictionary
:Python的 - 增量字典值
playlist = {u'user1': {u'Roads': 1.0, u'Pyramid Song': 1.0, u'Go It Alone': 1.0}}
,我試圖通過1.0
增加它的float
值:
user = playlist.keys()[0]
counts = playlist[user].values()
for c in counts:
c += 1.0
我已經走到這一步。
現在,我該如何update
的dictionary
與incremented value
?
請不要使用代碼爲降價的東西,不是代碼。 – JETM
我不知道你在說什麼.. –
你可以像這樣播放列表['user1'] ['Roads'] + = 1'。但是不確定你想要做什麼?你想同時增加everthing,還是隻選擇一些值? – Marcin