相关疑难解决方法(0)

Python:替换嵌套字典中的值

每当键为“ current_values ”时,我想用与“ integers ”相同的值替换值(格式为字符串)。

d = {'id': '10', 'datastreams': [{'current_value': '5'}, {'current_value': '4'}]}
Run Code Online (Sandbox Code Playgroud)

期望的输出:

d = {'id': '10', 'datastreams': [{'current_value': 5}, {'current_value': 4}]}
Run Code Online (Sandbox Code Playgroud)

python iteration dictionary

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

dictionary ×1

iteration ×1

python ×1