Some methods to handle dictionaries
Method | Description |
adict.has_key(k) | Returns TRUE (1) if the key k exists in the dictionary |
adict.keys() | Returns the list of dictionary keys |
adict.values() | Returns a list of dictionary values |
adict.items() | Returns a list of tuples (key, value) for each element of the dictionary |
adict.clear() | Deletes all elements of adict |
adict.copy() | Returns a copy of adict |
dic1.update(dic2) | Update the dictionary dic1 with the values of dic2 based on the values of the keys |
adict.get(k[,default]) | Equivalent to adict[k] but returns default if k cannot be found. |
adict.popitem() | Retrieves an element and deletes it from the dictionary |
No comments:
Post a Comment