建立一个空字典m,依次向m中添加键和值,首先输入的是breakfast,第二输入的是lunch,但输出结果是字典中元素的顺序并不是按照添加的顺序输出的,而是lunch排在第一,其次才是breakfast,难道字典的输出是随机的吗?
>>> m={} >>> m['breakfast']='canadian ham' >>> m['lunch']='tuna surprise' >>> m['dinner']='cheeseburger' >>> m {'lunch': 'tuna surprise', 'breakfast': 'canadian ham', 'dinner': 'cheeseburger'}
千巷猫影