示例字典
newlist={1:{1: {'_name': 'michael', 'id': '001', 'rating': '10', 'role': 'general_manager'},
2: {'_name': 'mohamad', 'id': '002', 'rating': '9.5', 'role': 'team_leader'},
3: {'_name': 'johnny', 'id': '003', 'rating': '9', 'role': 'developer'},
4: {'_name': 'nicholos', 'id': '004', 'rating': '9', 'role': 'tech_support'}},
2: {1: {'_name': 'michael', 'id': '001', 'rating': '10', 'role': 'general_manager'},
2: {'_name': 'mohamad', 'id': '002', 'rating': '9.5', 'role': 'team_leader'},
3: {'_name': 'johnny', 'id': '003', 'rating': '9', 'role': 'developer'},
5: {'_name': 'nawaz', 'id': '005', 'rating': '8.5', 'role': 'intern'}},
3: {1: {'_name': 'michael', 'id': '001', 'rating': '10', 'role': 'general_manager'},
2: {'_name': 'mohamad', 'id': '002', 'rating': '9.5', 'role': 'team_leader'},
4: {'_name': 'rogers', 'id': '004', 'rating': '9', 'role': 'tech_support'},
5: {'_name': 'nawaz', 'id': '005', 'rating': '8.5', 'role': 'intern'}},
4: {1: {'_name': 'michael', 'id': '001', 'rating': '10', 'role': 'general_manager'},
3: {'_name': 'johnny', 'id': '003', 'rating': '9', 'role': 'developer'},
4: {'_name': 'gargano', 'id': '004', 'rating': '9', 'role': 'tech_support'},
5: {'_name': 'nawaz', 'id': '005', 'rating': '8.5', 'role': 'intern'}},
5: {2: {'_name': 'mohamad', 'id': '002', 'rating': '9.5', 'role': 'team_leader'},
3: {'_name': 'johnny', 'id': '003', 'rating': '9', 'role': 'developer'},
4: {'_name': 'williams', 'id': '004', 'rating': '9', 'role': 'tech_support'},
5: {'_name': 'nawaz', 'id': '005', 'rating': '8.5', 'role': 'intern'}}}
for k in range(len(new_list)):
for l in k:
m = new_list[k][role]['tech_support']
我想从列表中获取所有“tech_support”角色。我如何访问字典中的键值,而我也在另一个字典中访问键值
阿晨1998
MYYA
慕码人8056858
相关分类