Read Catalogue
- A data type
- Two anonymous functions
- Three adorners, generators, iterators
- Four sort, sorted
- Five-list derivation, generator expression,
- Six and-or
- Seven map functions
- Eight multi-threaded multi-process Gil
- Nine OS, sys module
- Ten static methods, class methods, instance methods
- 11 Memory Management
- 12 *args **kwargs
- Thirteen-One Some database operations
- 14 default list parameter memory address l=[]
- The difference between IS and = =, in
- 16 single-Case mode
One data type 1 numbers
Integral type and floating point type
# int# Essence Age=int (#)# float float# Essence salary=float (3000.3)# binary, decimal, octal, hex
Other number types (understanding)
# Long Plastic (understanding) in Python2 (no long shaping concept in Python3): >>> num=2l >>> type (num) 'long' ># plural (learn) >>> x=1-2j >>> x.real 1.0 >>> X.imag- 2.0
2 string
# function: Name, gender, nationality, address, etc. description information # definition: in single quotation marks \ double quotes \ Three quotation marks, consisting of a string of characters name='Egon'# precedence operation: value by index (positive fetch + reverse fetch): only slices (Gu Tou regardless of tail, stride length) Len member operation in and not in
Remove blank strip split splits
Cycle
3 List
#Role: Multiple equipment, multiple hobbies, multiple courses, multiple girlfriends, etc.# definition: [] can have multiple values of any type, comma separated my_girl_friends=['Alex ','Wupeiqi',' Yuanhao ', 4,5] # Nature my_girl_friends=list ([...]) or L=list ('ABC')# Priority operation: Indexed access value (forward Access + reverse access): can be saved or sliced (Gu Tou regardless of tail, step) Length member operations in and not in
Append Delete loop
#PS: Reverse step l=[1,2,3,4,5,6]##[1, 2, 3]##[3, 2, 1] # #[6, 5, 4, 3, 2, 1]
4 tuples
# function: To store multiple values, in contrast to the list, the tuple is immutable (which can be used as a dictionary key), mainly to read the # definition: Compared to the list type, but [] replaced by () age= (11,22,33,44,55) Nature Age=tuple (( 11,22,33,44,55)# Priority operations: Value by index (positive fetch + reverse fetch): only slices (Gu Tou regardless of tail, step) length member operation in and not in loop
5 Dictionaries
#Function: Store multiple values, Key-value access, fast value#Definition: Key must be an immutable type, value can be any type info={‘Name‘:‘Egon‘,‘Age': 18,‘Sex‘:‘Male‘}#Essential Info=dict ({...})or Info=dict (name=‘Egon', age=18,sex=‘Male‘) or info=dict ([[ "name", " egon "age", 18 ' name", ' age ", "sex" ), None) # precedence operation: Access value by key: The available length Len member operation in and not in Delete key (), value values (), key value pair items () loop
#Resolving duplicate assignments with SetDefault‘‘‘SetDefault function 1:key exist, then do not assign a value, key does not exist, set the default value 2:key exist, return the key corresponding to the existing value, key does not exist, return is to set the default value D={}print (D.setdefault (' A ', 1)) #返回1d ={' a ': 2222}print (D.setdefault (' A ', 1)) #返回2222‘‘‘s=‘Hello Alex Alex say hello SB sb‘Dic={}words=S.split ()for word in words: #word= ' Alex ' Dic.setdefault (Word,s.count (word)) print (DIC) # Take advantage of the set, remove the repetition, reduce the number of cycles S= ' Hello Alex Alex say hello sb sb ' dic={}words=s.split () Words_set=set (words) for word in words_set:dic[word]=< Span style= "COLOR: #000000" >s.count (word) print (DIC)
6 Collection
# function: de-weight, relational operation, # definition: knowledge point review mutable types are non-hash type immutable types are hash types # definition collection: collection: can contain multiple elements, separated by commas , the elements of the collection follow three principles: 1: Each element must be an immutable type (hash, can be a key to the dictionary) 2: No duplicate elements 3: unordered note the purpose of a collection is to store different values together, and to do relational operations between different sets, without having to tangle with individual values in the collection # precedence operation: Length Len member operation in and not in| Collection & intersection- symmetric difference ==> , >=, <,<= parent set, subset
7 Summary of data types
Sub-footprint (low to high) per storage space
Numeric string collection: unordered, that is, unordered storage index related information tuple: ordered, need to store index related information, immutable list: Orderly, need to store index related information, variable, need to deal with the data to change the dictionary: unordered, need to save key and value mapping information, variable, need to deal with data deletion and modification
Differentiate by number of stored values
Scalar/Atomic Type |
Number, string |
Container type |
list, tuple, dictionary |
By Variable immutable distinction
Variable |
List, dictionary |
Not variable |
Numbers, strings, tuples |
Differentiate by Access order
Direct access |
Digital |
Sequential access (sequence type) |
String, list, tuple |
Key value access (mapping type) |
Dictionary |
A functional Knowledge system
1 What is a function? 2 Why use a function? 3 Classification of functions: Built-in functions and custom functions 4 How to customize function syntax define parametric functions, and application scenarios with parametric functions to define parameterless functions, and application scenarios for parameterless functions to define empty functions, and application scenarios for empty functions 5 Call function How to call function function parameter application: Formal parameter and argument, positional parameter, keyword parameter, default parameter, *args,**KWARGS6 higher order function (function object) 7 Function nesting 8 scope and namespace 9 adorner and generator and co-op function one-by-one ternary operation, list parsing, generator expression, recursive invocation of the function of the three functions 14 for process programming and functional programming
The basis of two functions
Links: http://www.cnblogs.com/linhaifeng/articles/7531972.html
Three function objects, function nesting, namespaces and scopes, adorners
Links: http://www.cnblogs.com/linhaifeng/articles/7532497.html
Four iterators, generators, process-oriented programming
Links: http://www.cnblogs.com/linhaifeng/articles/7580428.html
53-Tuple expressions, list derivations, generator expressions, recursion, anonymous functions, built-in functions
Links: http://www.cnblogs.com/linhaifeng/articles/7580830.html
Six function drafts
This is the draft part of the above content, the reader does not need to see
Draft: http://www.cnblogs.com/linhaifeng/articles/6883726.html
Seven jobs
Job Requirements:
Analog implementation of an ATM + shopping mall Program
- Quota 15000 or Custom
- Realize shopping mall, buy things to add shopping cart, call credit card interface Checkout
- Can withdraw, handling fee 5%
- 22nd monthly Billing, 10th monthly repayment date, overdue, according to the total amount owed 5 daily interest
- Multi-Account Login support
- Support transfer between accounts
- Record monthly daily consumption flow
- Provide repayment interface
- ATM Record Operation Log
- Provide management interface, including adding account, user quota, freezing account, etc...
- Decorator for user authentication
Sample Code HTTPS://GITHUB.COM/TRIAQUAE/PY3_TRAINING/TREE/MASTER/ATM
Simple flowchart: https://www.processon.com/view/link/589eb841e4b0999184934329
---restore content ends---
Python Knowledge Review