나는 오랫동안 dicts리스트를 가지고 일해 왔으며, 내가 원하는 방식으로 정렬하는 방법을 고집하는 것처럼 보일 수 없다. 여기에 짧은 예는 다음과 같습니다dicts 목록을 파이썬에서 하나의 dict로 결합하는 가장 좋은 방법은 무엇입니까?
artist_movement = [
{'movement': 'Abstract Expressionism', 'artist': 'William Baziotes'},
{'movement': 'Modern Art', 'artist': 'Alexander Calder'},
{'movement': 'Abstract Expressionism', 'artist': 'Grace Hartigan'},
{'movement': 'Cubism', 'artist': 'Pablo Picasso'},
{'movement': 'Cubism', 'artist': 'Peter Blume'},
{'movement': 'Abstract Expressionism', 'artist': 'Norman Wilfred Lewis'},
{'movement': 'Modern Art', 'artist': 'Lucian Freud'}
]
나는이 비슷한 방식으로 이동하여 예술가를 정렬하고 싶습니다 : 어떤 도움
artist_by_movement = [
{'Abstract Expressionism':['William Baziotes', 'Grace Hartigan', 'Norman Wilfred Lewis']},
{'Modern Art':['Alexander Calder', 'Lucian Freud']},
{'Cubism':['Peter Blume', 'Pablo Picasso']}
]
감사합니다!
이 비슷한 뭔가 SO/구글에 봤어 할 수
(아마도 그들 더 흥미로운 정보가있다)? 병합 딕테이션이 많이 발생합니다 ... –
[this] (http://stackoverflow.com/questions/2365921/merging-python-dictionaries)가 도움이됩니까? –
네, 고맙습니다. (열쇠로 딕트 목록을 병합하는) 제 문제에 직접적으로 관련되어 있지만 아무 것도 찾지 못했다는 좋은 설명을 몇 시간 보았습니다. – djangonoob