首页 > 代码库 > Python字典问题

Python字典问题

刚玩玩python,这尼玛,不理解,难道是按数字排序,慢慢发现!!

源码如下:

menu={‘1.‘:‘add to sum‘}
menu[’2.‘]=‘averg to numbers‘
menu[‘3.‘]=‘exit‘

结果:

1 add to sum
3 exit
2 averg to numbers

源码如下:

menu={1:‘add to sum‘}
menu[2]=‘averg to numbers‘
menu[3]=‘exit‘

结果:

1 add to sum

2 averg to numbers
3 exit

 

Python字典问题