To create a dictionary type:
Zidian = {} or Zidian = Dict ()
[]: Use the index inside square brackets
Len (Zidian): Number of test key-value pairs
In: Whether the key is in the dictionary, returns a Boolean value
Dictionary method:
Items (): A list of tuples for all key-value pairs
Keys (): List of all keys
VALUES (): All Worthwhile lists
Copy (): Shallow copy Dictionary
To create a set type:
Nullset=set ()
Dictionary method:
Len (); Number of elements
Intersection: Create a new collection, take the same part of the two collection intersection () such as Aset.intersection (Bset)
Aset.union: Create a new collection, remove all elements of two collection (Bset)
Difference set: Aset.difference (Bset)
Symmetry difference: Remove elements that are not shared in the two collection symmetric_difference
Subset and superset: Aset.issubset (Bset), Aset.issuperset (Bset) return value is Boolean
Add (Element)
Clear (): Empty
Remove (Element) and discard (element): Deletes the elements. element does not exist remove error, discard () does not
Copy (): Shallow copy
This article is from the "leaf" blog, please be sure to keep this source http://fshine.blog.51cto.com/6122608/1569878
Python Learning Dict (dictionary) type and set type