目录
- 字典的创建
- 字典的访问 ( List转换 )
- 字典的遍历
- 字典的添加
- 字典的合并
- 字典的删除(清空)
- 字典的其他操作
- 实例(字符频率统计)
- 字符串转字典(eval)
- "字典列表"的排序
dict:dictionary
item:项/项目
default:[计]缺省、默认
连接:【列表中出现次数最多的元素】
一:字典的创建
字典的创建方式
dict1 = { "A":1,"B":2,"C":99 } # 直接创建
x = ["A","B","C"]
y = [1,2,99]
print(dict(zip(x,y))) # {'A': 1, 'B': 2, 'C': 99} => dict()与zip()压缩
dict5 = {}.fromkeys(["A","B","C"],"Content") # {'A': 'Content', 'B': 'Content', 'C': 'Content'} => 使用fromkeys()
dict6 = {}.fromkeys(["A","B","C"]) # {'A': No