Make up: 17 to 18 set of study notes

Collection (set) s = set (discharge may be iterative value: String tuples dictionaries)      S = SET ( "Hello")

Defining a set: of different elements, the number of values ​​is a set of unordered may hash (immutable values).

1. The different elements (like elements will be automatically discarded addition)

2. unordered (from a set of non-paid using standard value, because it is out of order)

3. immutable values ​​stored (number string tuple)

s = { "test", 12,34, (1,3, "hh")} ------ pooled (braces)

View type: Use the type (s)

 

Built-in methods for the collection:

 add (value added, only different values)

clear (empty)

copy (copies)

pop (delete, delete any value unordered)

remove (delete the specified element, if you delete the wrong element does not exist will burst)

discard (delete the specified element does not exist but does not burst wrong, continue to execute the following program)

 

A set of relational operation intersection, difference, and correlation operation

1、

Guess you like

Origin www.cnblogs.com/jianchixuexu/p/11518537.html