字典

来源:互联网 发布:p结婚证软件 编辑:程序博客网 时间:2024/05/16 14:20

字典

两个列表

可用slogan[brand.index('')]
创建字典

dic = {‘key’:’值’,”:”}
dic2 = dict(((”,105),(”,132)))
dic3 = dict(1=’2’,3=’4’)
dic4 =

查用字典

dic[”]` dic[”] = ” “` dict1 = {}

dict1.fromkeys((1,2),(‘one’,’two’,’three’))

{1:(‘one’,’two’,’three’,2:(‘one’,’two’,’three’)}

几个方法

.keys(),.values(),.items(),.get(),.clear(),pop(),popitem(),setdefaults(),update()

集合

1.与字典的区别就是没有体现映射 2.而且具有唯一性,无序性 3.set(),frozenset 4..add(), .remove()