我很抱歉,如果這是一個重複的問題,但我找不到任何類似的例子,所以尋求你的幫助。如何在Python中初始化多維數組?
lookup = {}
# These values will be filled by DB lookup service at runtime
# Maximum array length for category is unknown before program start
# Format [Lookup Category], [Lookup Key], Lookup Id
lookup['name']['John'] = 1
lookup['name']['Jane'] = 2
lookup['name']['Joe'] = 3
lookup['gender']['Male'] = 1
lookup['gender']['Female'] = 2
lookup['country']['Japan'] = "jp"
lookup['country']['China'] = "ch"
print lookup['name']['Jane']
print lookup['gender']['Female']
print lookup['country']['China']
這個問題非常含糊......你似乎有一些涉及嵌套字典的問題,但這些都是我現在可以從中得到的。 – l4mpi