The second punch learning python

1, the python data into variable data (list, set, Dictionary) and immutable data (number, string, tuple)

  in value or may detect whether or not in the list or dictionary; while dictionaries are checked prior to each use is cumbersome () method can save time with a get

  The list has the following methods:

    () Index: a pass value if the restructuring present in the list, it returns the following table

    append (): value added at the end of the list

    insert (): added value at the beginning of the list

    remove (): Delete the value from the list, multiple occurrences delete only once

    sort (): the value of the sorted list, and sorting is now directly change the order of the list, the return value need not be recorded

  The dictionary has the following methods:

    key (), values ​​(), items (): returns a list similar to values ​​corresponding key value, key - value; as to obtain a real list, a list of similar values ​​put return value to the function list

    get (): value from the dictionary, there are two parameters, the first parameter value is to be retrieved, the second parameter value is returned if the standby key does not exist.

    setdefault (): Check whether there is a key, a first parameter is the key to check the second parameter value to be set is the time to check if the bond is absent.

  String has the following methods:

 

Guess you like

Origin www.cnblogs.com/xujia-go/p/11164676.html