从my_dict字典中打印65这个值 my_dict = { "program": { "imba": { "year": "2", "tracks": { "im": 60, "ba": 65 } } } }
时间: 2024-08-16 13:04:19 浏览: 80
为了从给定的`my_dict`字典中打印出键为"tracks"、值为"imba"的嵌套字典里的键为"tracks",对应的值65,你可以按照以下步骤操作:
```python
my_dict = {
"program": {
"imba": {
"year": "2",
"tracks": {"im": 60, "ba": 65}
}
}
}
value_65 = my_dict["program"]["imba"]["tracks"]["ba"]
print(value_65) # 输出:65
```
如果你想要获取整个路径"tracks/imba/tracks/ba"的值,可以直接通过链式索引获取:
```python
value_65 = my_dict["program"]["imba"]["tracks"]["ba"] # 直接获取结果
```
阅读全文