啊峰哥

4.1字典

1.生成字典

    names = [] ,salaries = [] ,dict[zip(names,salaries)] 

    dic = {key1:value1,key2:value2}

    dic = dict([[key1,value1],[key2,value2]])

    dic = dict(([key1,value1],[key2,value2]))

    dic =  dict(key1=value1,key2=value2)

    sorted(dic)

2.字典基本使用

   查找: dic[keys]或者dic.get(keys)不会返回错误

   更新:dic[key1] = value1

   添加:dic[key2] = value2

   判断:value in dic

   删除:del dic[key1]

3. 常用方法

   image

posted on 2018-05-12 22:48  啊峰哥  阅读(97)  评论(0编辑  收藏  举报

导航