#!/usr/bin/env python # -*- coding:utf-8 -*- ‘‘‘ 字典 dict 键 :值 对 键不可重复 重复会覆盖 无序 表,不能作为键
布尔值 True == 1 False == 0 不建议作为键 会冲突覆盖 ‘‘‘ zidian1 = { "k1" : "v1", "k2" : "v2", "k3" : "v3", "k4" : "v4", "k5" : "v5", "k6" : "v6", "test" : "test" } del zidian1["test"] print(zidian1) print(zidian1["k1"]) zidian1_len = len(zidian1) print(zidian1_len) for item in zidian1: print(item,":",zidian1[item],"\t",end="") print() for item in zidian1.keys(): print(item,"\t",end="") print() for item in zidian1.values(): print(item, "\t", end="") print() for k,v in zidian1.items(): print(k,":",v,"\t",end="")
运行结果