Python에서 dict의 사전을 초기화하는 가장 좋은 방법은 무엇입니까? 이 질문에 이미 답변이 있습니다. 중첩 된 사전을 구현하는 가장 좋은 방법은 무엇입니까? 20 답변 Perl에서 여러 번 다음과 같이 할 것입니다. $myhash{foo}{bar}{baz} = 1 이것을 파이썬으로 어떻게 번역합니까? 지금까지 : if not 'foo' in myhash: myhash['foo'] = {} if not 'bar' in myhash['foo']: myhash['foo']['bar'] = {} myhash['foo']['bar']['baz'] = 1 더 좋은 방법이 있습니까? class AutoVivification(dict): """Implementation of perl's autovivificat..