Recommendation 1: Understanding the concept of pythonic
The Zen of Python
Beauty is better than ugliness (Python's goal of writing graceful code) is better than obscure (beautiful code should be clear, naming specification, style similar) simplicity is better than complexity (graceful code should be concise, not complex internal implementations) complex than messy (if complex unavoidable, The code can not be difficult to understand the relationship, to keep the interface concise) flat than nesting (graceful code should be flat, not too many nesting) interval than compact (graceful code has the appropriate interval, Do not expect a line of code to solve the problem) readability is important (beautiful code is readable) even in the name of the practicality of the special case, do not violate these rules (these rules are paramount) do not tolerate all errors unless you are sure you need to do this (accurately capturing exceptions, not writing Except:pass Style code) when there are many possibilities, do not try to guess but try to find one, preferably the only obvious solution (if not sure, use the poor lifting method) Although this is not easy, because you are not the father of Python (here Dutch refers to Guido) It may be better not to do it, but it's better not to do it without thinking about it (before you do it) If you can't describe your plan to someone, it's certainly not a good idea; and vice versa (Program evaluation criteria) Namespaces is a wonderful concept, we should use (advocacy and call) python Implementation Quick Sort mode def px (PX1): l=[];g=[] If Len (px1) <=1:return px1 pivot=px1.pop () for x in Px1:if x<= pivot:l.ppaned (x) else:g.append (x) retu8rn px (L+[PIVOT]+PX (g)) px ([]) code style (packaging/unpackaging) mechanism, as follows A,b=b,a (variable Exchange) Traverse capacity for I in List:pass iterator, as follows with open (A.txt) as f: f.read () python slice (sliced) a=[1,2,3,4] Print A[0],a[-1],a[0::],a[::-1],a[0::2] uses Python's built-in methods to manipulate the print list (reversed (a)) string format ' name=%s,year=%s '% (' 01 ', ' 1990 ') dictionary format value={' a ': 1, ' B ': 2}print '% (a) s and% (b) s '% (value) efficient formatting ' {0} and {1} and {2} '. Format ( python) library or frame
From flask import Flask
App=flask (__name__)
@app. Route ('/')
def hello ():
Return ' Hello '
If __name__== ' __main__ ':
App.run ()
Python91 a suggestion (recorded here)