# Auther: Aaron Fan #示例1:#存储所点披萨的信息pizza = { ‘外皮‘:‘厚的‘, ‘配料列表‘:[‘香菇‘, ‘奶酪‘],}#概述所点的比萨print(‘您点了一道"%s-外皮"的比萨信息: ‘ % pizza[‘外皮‘])for 配料 in pizza[‘配料列表‘]: print("\t%s" % 配料) #示例2:最喜欢的语言 = { ‘张三‘:[‘python‘,‘ruby‘], ‘李四‘:[‘c‘], ‘赵钱‘:[‘go‘,‘ruby‘], ‘孙立‘:[‘python‘,‘scala‘],}for name,languages in 最喜欢的语言.items(): #.itmes(),它返回一个键值对列表 print("\n%s最喜欢的语言是: " % name) for language in languages: print("\t%s" % language.title())
时间: 2024-10-12 08:31:16