day08-- built-in method Summary

List type built-in method

List Properties

Stored value or a plurality of values: a plurality of values

Ordered or disordered: Ordered

Variable or immutable: Variable Data Type

Priority grasp

  1. By index value (positive value + antiporter value), may be taken to deposit

    list[0]='a'

  2. slice

    list[start:stop:step]

  3. Length len

    len ( list )

  4. Members and not in operation in

    'a' in 'abc' ==》True

    'a' not in 'abc'==》False

  5. Add append

    lis.append(object)

  6. Delete del

    the lis

  7. cycle

    for i in lis:

    ​ print i

Need to know

  1. insert insert

    lis.insert(index,object)

  2. pop pop

    lis.pop(index)

    index may be empty, the default value is the last pop

  3. remove remove (not being given)

    lis.remove(object)

  4. count the number

    lis.count(object)

  5. Gets the index index

    lis.index(object,start,stop)

  6. clear Clear Array

    lis.clear

  7. copy replication (different id)

    lis.copy()

  8. extend extension

    lis.extend(iterable)

  9. reverse reverse

    lis.resverse()

  10. sort sort

    lis.sort(key,reverse)

Tuple built-in method

Tuple property

Is the immutable list

Is defined: a = (); a = tuple ()

Stored value or a plurality of values: a plurality of values

Ordered or disordered: Ordered

Variable or non-variable: immutable data type

Built-in method

Priority grasp

  1. Index values

  2. Sections (care regardless of the end, step)

  3. Length len

  4. Members and not in operation in

  5. cycle

  6. count

  7. index

    Use reference list

Dictionary built-in method

Dictionary property

Stored value or a plurality of values: a plurality of values

Ordered or disordered: disordered

Variable or immutable: Variable Data Type

Built-in method

Priority grasp

  1. Access key press value: deposit may be desirable

  2. Length len

  3. Members and not in operation in

  4. Delete del

  5. Button keys (), the value of values ​​(), on the key-value items ()

    dic.keys()

    dic.values()

    dic.items()

  6. (Loop is withdrawn key)

Need to know

  1. get Gets

    dic.get(key)

  2. update update

    dic.update ( {} key-value pair )

  3. fromkeys quickly create a dictionary

    dict.fromkeys([keys],value)

  4. setdefault setting default values

    dic.setdefault(key,default)

A collection of built-in method

Stored value or a plurality of values: a plurality of values, the data type is immutable

Ordered or disordered: disordered

Variable or immutable: Variable Data Type

Built-in method

Priority grasp

Length len

Members and not in operation in

| Union, union

& Intersection, intersection

-差集、difference

^ Symmetric difference, symmetric_difference

==

Parent Set:>,> =, issuperset

Subsets: <, <=, issubset

Need to know

  1. add
  2. remove
  3. difference_update
  4. discard
  5. isdisjoint

Guess you like

Origin www.cnblogs.com/Sheppard/p/11304847.html