Python3.x Study Notes 3, python3.x Study Notes
1. Set
A set is an unordered, non-repeated data combination. Its function is as follows:
> Deduplication: automatically removes duplicates when a list is converted to a set.
> Link test: tests the intersection, difference set, and union of the two groups of data.
2. relational operation
Intersection: set1.intersection (set2)
Union: set1.union (set2)
Difference set: set1.difference (set2) # In set1, set2 does not
Subset: set1.issubset (set2) # determine whether set1 is a subset of set2
Parent set: set1.issuperset (set2) # determines whether set1 is the parent of set2.
Symmetric difference set: set1.symetric _ difference (set2) # Remove the union of the two sets, and retrieve them none.
Determine whether there is an intersection: set1.isdisjoint (set2)
3. Operator relationship Calculation
Intersection :&
Union: |
Difference set :-
Symmetry difference set: ^
Subset: <=
Parent set:> =
4. Basic Set Operations
Add: set1.add (x) # add an item
Update: set1.update ([10, 37, 45]) # add multiple
Remove: set1.remove () # You can delete an item. If it does not exist, an error is returned.
Remove: set1.discard () # remove an item. If it does not exist, no error is returned. The return value is none.
Measurement length: len (set1)
X in set1 # test whether x is a member of set1
X not in set1 # test whether x is not a member of set1
Shortest: set1.copy ()
Set1.pop () # delete any set1zhong Element
5. File Operations
(1) open the file, get the file handle, and assign a value to a variable.
(2) operate the file through a handle
(3) close the file
6. File Operations
Https://www.cnblogs.com/nulige/archive/2016/12/06/6037752.html