- 构造字典
# 直接构造
dic = {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'A':10,'B':11,'C':12,'D':13,'E':14,'F':15}
# 通过list构造
a = [1,2,3]
b = {key:value for value,key in enumerate(a)}
output:
2. 字典取内容
a = dic['0']
a 0
# 直接构造
dic = {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'A':10,'B':11,'C':12,'D':13,'E':14,'F':15}
# 通过list构造
a = [1,2,3]
b = {key:value for value,key in enumerate(a)}
output:
2. 字典取内容
a = dic['0']
a 0