Getting Started with Python (v) - to derive data

1.data.strip () split ():. Method chaining (read from left to right)
The first method strip () is applied to the data line in the data, remove unwanted string whitespace. Results removing whitespace () processed by the second method of split, that is to create a list.

2. Python sort the data
in situ ordering: arranging the data in the specified order, and then replace the original data with the data sorted. The original order will be lost. Sort method ().
Copy Sort: arrangement data specified order, ordered to return a copy of the original data. The order of the original data will still be retained, just sort of a copy. The method is sorted ().

3.print (sorted (james)): Function chain strings (read right to left)
allows a series of functions for data applications. Each function takes the data, its operation is completed, the results passed on down to the next function.

4. By default, sort () and sorted () are arranged in ascending order of data. To be in descending order, then, need to pass parameters **** reverse = True.

The list comprehension
Here Insert Picture Description
1) .clean_mikey: Create a new list
2) sanitize: Specifies a conversion
3) each_t: Select the target identifier to be used and applied to each data item
4) mikey: a list of existing

6. Remove duplicates a set
of data items in the set are Python disordered, and can not be duplicated. If you try to add a set of a data item, which already contains the collection of data items, Python will ignore.
Creating an empty set using the set (), it can also be done step by creating and populating the collection. Braces may be provided between a data list, or a list of existing as specified set () parameter which is a function of the plant.
Here Insert Picture Description
The factory function: to create some kind of new items.

7. "slice": access multiple list items from a list.

Here Insert Picture Description
8. If you have the following code:
Here Insert Picture Description
can be used to derive a list rewritten as:
Here Insert Picture Description

Released nine original articles · won praise 0 · Views 312

Guess you like

Origin blog.csdn.net/weixin_44739916/article/details/104292426