问题
I have a nested dictionary in Python with the following structure:
d= {
'name': 'test',
'IBM': 146.48,
'MSFT': 44.11,
'CSCO': 25.54,
'micro': {'name': 'test', 'age': 1}
}
In my code I want to change the value of the first key name
.
When I do:
for k, v in d.items():
d[k] = newvalue
All the values of keys = name change to my new value. But I want to only change the value of the first key name
.
How to fix this?
来源:https://stackoverflow.com/questions/65994092/differentiate-between-two-values-with-same-key-in-a-nested-dictionary