import builtins #key, value d = {'a':1, 'b':2} #dir print("dir\n", dir(d)) #length print("\n\nlength:",len(d)) #print value print("value", d['a']) #get value print("get value", d.get('a')) #print key and value for k,v in d.items(): print(k, " ,", v) #clear print("Clear:", d.clear()) print("length:",len(d))
參考資料:
http://docs.python.org/3/tutorial/datastructures.html#dictionaries