#dict字典, in fact, rather than the dictionary called Key-value more appropriate, do not know the name is how to come, this can be used to engage in user name and password, but this does not use the database is too low
#用花括号 {} expands, commas separate each element, each element must have key and Value,key and value separated by colons
A = {' A ': 1, ' B ': 2} # ' A ', ' B ' is key,1,2 is value
A.get (' a ') #获取key对应的value, the result is 1
A.keys () #得到字典中全部的key, the result is [' A ', ' B '], a list, how smart! How thoughtful!
A.pop (' a ') #删除一个key元素, showing 1, the result is {' B ': 2}
b = {' C ': 3}
A.update (b) #把另一个字典加进来, the result is {' C ': 3, ' B ': 2}
A.values () #返回全部value, the result is [3,2], a list, too TM Smart!!! Here I come again ...
A[' B '] #和get一样, get key corresponding to the value, that want get do what, well, I also do not understand, foreigners good habits I understand, also may function different, have know kindly inform
A[1] #这个报错的, there is no 1 this key, so .... Dict cannot slice
Python Basic _ Type _dict