- len(myDict)
- eletment in myDict
- for key in myDict:
- for key in myDict.keys()
- for key, value in myDict.items():
- for value in myDict.values():
- myDict,ckear()
- aDict,update(bDict) - for each key in bDict, updates aDict with that key/value pair
zip() is the built-in function
- zip("abc", [1, 2, 3]) --> [(‘a’,1),(‘b’,2),(‘c’,3)]
- dict(zip("abc", [1, 2, 3]) -->{'a': 1, 'c': 3, 'b': 2}
aString = "\n".join(aList)
aList = aString.split("\n")
OrderedDict
reports = collections.OrderedDict()
the OrderedDict will remember the sequence of key insertion
No comments:
Post a Comment