我有两个带有列表值的字典;旧的和新的版本。
旧列表:
$('#chart').remove();
$('#canvasContainer').append("<canvas width='10' height='10' id='chart' style='height:10px; width: 100px;'></canvas>");
var chartId = document.getElementById('chart').getContext('2d');
var chart = new Chart(chartId, chartTheme);
新列表:
.destroy()
如果第一个列表值更改(在这种情况下,新列表上的颜色),我想更新列表的第二个值(数字,假设为0)。
Python3中最好的解决方案是比较两个字典值列表之间的第一个字典值,如果第一个列表值已更新,则更新第二个字典列表值?
答案 0 :(得分:1)
您可以遍历old_dict并对照new_dict检查其值,如果它们不同意,请更改它们。
for k,v in old_dict.items():
if k in new_dict and v[0] != new_dict[k][0]:
new_dict[k][1] = '0';