1. List
list[start: End: Increment]
Value passing and address passing
A = [2,1= a # address delivery B = a[:] Value passed a.sort ()print a # [up] print b #[+]
2. Sorting sort ()
d = {1: " s ", 2:" a " sorted (D.items (), key = lambda x:x[1] ) /* Sort by the 2nd element of the list element */
# Sorted (iterable, cmp=none/* function */, key=none/* function */, Reverse=false) = ['aaa','a','aa' = len)#The key value is the total function to be called print ll
Print sorted ("Sorting1234", Key=lambda x: (X.isdigit (), X.isdigit () and int (x)% 2 = = 0, X.isupper (), X.islower (), x)) #[' G ', ' i ', ' n ', ' O ', ' r ', ' t ', ' S ', ' 1 ', ' 3 ', ' 2 ', ' 4 ']
3. anonymous function lambda
# Lambda parameter: return value Lambda x:x+1
4....for. ... in ... if ...
A = [All-in-a-z]printforif i>0]
5.filter map Reduce
Filter (function, sequence): Executes function (item) on item in sequence, and the item that executes the result of true is composed of a list/string/ Tuple (depending on the type of sequence) returned
Print Lambda x:x!='a'abcd ') #' BCD '
Map (function, sequence): Executes function (item) on item in sequence, and the result of execution consists of a list return:
Print Lambda x:x+1, Range (3)) #[+]
Reduce (function, sequence, starting_value): Calls the function in the order of the item in the sequence, and if there is a starting_value, it can also be called as an initial value. For example, you can use the list to sum
Print Lambda x,y:x+y, Range (3), ten) #
6. Generator Generator
for in range (3)) for in a:print I
7. Range(start , end , increment )
Print Range (1,9,2) #[1, 3, 5, 7]
8...? ...:...
if else b # fully equivalent andor [c]) [0] (andor C # not exactly equivalent, B cannot be false
F
Pythonic Programming example and brief analysis