The structure of centrally stored data that is common in 1.python:
List
Collection
Dictionary
Meta-group
String
Dual queue
Heap
One of the most common is the list, dictionary.
2. Here are some elements that use loops to get a list of dictionaries
1>>> dic={'name':'Zhangsan',' Age': 24,' City':'Jinhua'}2>>> forKey,valueinchDic.items ():3 Print(Key,value)4 5 6 name Zhangsan7Age 248City Jinhua
Loop Get list
>>> lists=[1,2,3,4,5] for in lists: item+1 23456
Some introduction to 3.python functional programming
Some of the functions of Python about function programming are:
Map (function,list), map function
Filter (), filtering function
Reduce (), statute function
Lambda functions
List-Generated
1 def Inc (X):return x+12 >>> list (map (inc,lists))3 [2, 3, 4, 5, 6 ]4 use a lambda expression for a function, abbreviated to one line of code 5 >>> items=[1,2,3,4]6 >>> list (map (Lambda x:x+1), items)7 [2, 3, 4, 5]
use of the filter function >>> list (filter (lambda x:x<3), items) [1, 2]
1 The reduce function needs to import the reduce module 2 from Import Reduce 3 >>> reduce ((lambda x,y:x/y), items)4 0.0416666666666666645 The last concept of functional nominal is the list-generated 6 for in range (3)]7 > >> s8 [0, 1, 4]
Python-functional programming, List-generation