#字典与列表 #列表 spam = ['bat', 'hat', 'cat', 'fat'] print(spam[0:2]) #列表只能引索整数 #元组 #元组是不可变的列表 eggs = ('hello', 12, 'aa') #字典 mycat = {'size': 'fat', 'color':'orange', 'disposition': 'load'} #对比1:与列表相比,字典的可以引索更多的数据类型,字典的引索称为键 #如size为键,fat为对应的值 #对比2 #字典里的项是不排序的
python入门:列表与字典区别
最新推荐文章于 2024-07-26 17:36:26 发布