Python上课笔记6:字典

这一章需要学习的东西就多了;
当然林老师的课件总结的很好,我主要还是靠刷题来巩固知识:

#6-5
a = {"nile" : "egypt" , "zhuliang" : "china" , "henghe" : "india"}
for key in a.keys():
    print(key)
for value in a.values():
    print(value)

cities = {"shenzhen" : {"num" : 2000 , "country" : "china"} , "guangzhou" : {"num" : 200121234440 , "country" : "china"} , "shanghai" : {"num" : 200120 , "country" : "china"}}

for key , value in cities.items() :
    print(key + ":" , end = " ")
    for a , b in value.items() :
        print (a + " is " + str(b) , end = " ")
    print('\n')

你可能感兴趣的:(python)