set a bit:1, access Speed 2, born to solve the problem of repetition
Tuple differs from set: tuple repeatable, set not repeatable
Gen Jie Collection 1
>>> S1.add (' Alex ')
>>> Print (S1)
{' Alex '}
>>> S1.add (' Alex ')
>>> Print (S1)
{' Alex '}
Create a Collection 2
>>> set ([' Alex ', ' Eric ', ' Tony ')
{' Tony ', ' Eric ', ' Alex '}
Find the difference and rebuild a new collection
>>> S1 = set ([' Alex ', ' Eric ', ' Tony ')
>>> s1.diference ([' Alex ', ' Eric '])
{' Tony '}
>>> S1 = set ([' Alex ', ' Eric ', ' Tony ')
>>> s1.difference ([' Alex ', ' Eric '])
{' Tony '}
>>> s2=s1.difference ([' Alex ', ' Eric '])
>>> S2
{' Tony '}
>>> Print (s2)
{' Tony '}
Difference_update Modify the original collection to present the specified element
>>> S1
{' Tony ', ' Eric '}
>>> s3 = S1.difference_update ([' Tony '])
>>> S1
{' Eric '}
Pop takes an element from the original collection and can accept the element with another variable.
>>> S1 = set ([' Alex ', ' Eric ', ' Tony ')
>>> s2 = S1.pop ()
>>> S2
' Alex '
>>> S1
{' Tony ', ' Eric '}
>>>
Python Learning Note Day3