Personal summary of the collection of python

Personal summary of the collection of python

A variable:

1, types of variables: strings, numbers, lists, dictionaries, tuples

2, classification variables:

  1, the variable immutable:

    (1) variable: lists, dictionaries

    (2), can not be changed: string, number, tuple

  2, the access order:

    (1) sequential access: strings, lists, tuples

    (2) mapping: Dictionary

    (3), direct access to: Digital

    (4), storing the number of elements

        a, container type: lists, tuples, dictionaries
        B, atoms: number, string

Second, the definition set and Basic Operation

       1, is defined: a collection of different elements of the set is a set of hash values ​​disordered array can be used as a dictionary key

       2, Characteristics: different elements, unordered, immutable elements

       3, the set of definitions:

    (1)、s={1,2,3}

    (2), defines a variable set of set: s = set ( "hello")

    (3), the definition of a set of immutable frozenset: s = frozenset ()

  4, methods of operation:

    (1), s.pop () randomly remove elements

    (2), s.remove () Removes the specified element, remove the element does not exist, an error

    (3), s.discard () Removes the specified element, delete element does not exist, no error

    (2), s.add () additive element

    (3), s.clear empty set

       (4), s1.update (s2) update the plurality of elements

  5, the relationship between the set of operations

    (1), the intersection: p_w & p_s

    (2), and sets: p_w | p_s

    (3), difference: p_w-p_s

    (4), cross the complement: p_w ^ p_s

 

 

Guess you like

Origin www.cnblogs.com/zhaoqing-cao/p/12294755.html