我有一个字典,其中包含名为tick_list
的字典,如下:
(1, {'Wins: ': 0, 'WinRate: ': 0, 'Total: ': 0})
(2, {'Wins: ': 0, 'WinRate: ': 0, 'Total: ': 0})
(3, {'Wins: ': 0, 'WinRate: ': 0, 'Total: ': 0})
(4, {'Wins: ': 0, 'WinRate: ': 0, 'Total: ': 0})
(5, {'Wins: ': 0, 'WinRate: ': 0, 'Total: ': 0})
我想说我想在字典5 Wins:
中添加1。我试过了:
tick_list[5]["Wins: "] += 1
但结果是:
(1, {'Wins: ': 1, 'WinRate: ': 0, 'Total: ': 0})
(2, {'Wins: ': 1, 'WinRate: ': 0, 'Total: ': 0})
(3, {'Wins: ': 1, 'WinRate: ': 0, 'Total: ': 0})
(4, {'Wins: ': 1, 'WinRate: ': 0, 'Total: ': 0})
(5, {'Wins: ': 1, 'WinRate: ': 0, 'Total: ': 0})
有关为何会发生这种情况的任何解释?我如何才能将5添加到只有5的字典?
忽略括号()
而不是{}
,我使用for循环打印字典。