Three levels of python learning notes,
1. Correct Dictionary (others') 2 zone = {3 'North China': {'shandong ': {'qingdao': ['sifang '] ,},}, 4 'south': {'jiangsu ': {'suzhou': ['canglang '] ,},}, 5} 6 is not an error, but an unreasonable Dictionary (mine) 7 dic_china = {8 "Municipalities": {"Beijing": ["Dongcheng District",] ,}, 9 "Province": {"Zhejiang Province": {"Hangzhou City ": ["gongshu district",], },} 10}
Comparing the two dictionaries, it is not difficult to find that the dictionary I created actually belongs to the second-level dictionary rather than the third-level dictionary.
Misunderstanding:
I think the level of the dictionary is determined by the "long wooden board", that is, the dictionary "china" ---> Dictionary "Province" ---> Dictionary "Zhejiang Province ", in fact, it is determined by the "short board", that is, the dictionary "china" ---> the dictionary "municipality ",
Final result:
Code: dic_china ['province '] ['zhejiang province']. keys (): Yes. An error is returned when the code is executed: Unresolved attribute reference 'key' for class
Code: zone ['North China'] ['shandong ']. keys (): Correct. The output value is Qingdao.
Ps: I tried again and found that dic_china ['province '] ['zhejiang province'] was directly output. The output result is Hangzhou city, that is: I originally guessed {"Hangzhou City ": ["gongshu district",],} The conjecture that python recognizes as a value seems to be wrong. I really don't understand it. I still need to continue learning the dictionary, I don't know if there are any technical experts who can solve this problem ??