The first day of the formal study of Python, the web found a Python tutorial, with exercises, and installed Ubuntu.
This is the study note:
1List[]: variable, append/1,insert/2,pop/index?2 3 tuple (): unchanged4 5dict{}: Variable, values/0,itervalues/0,values/0,iteritems/0,items/06 7Set ([]): Variable, add/1,remove/Index8 9 TenSTR:. join/list. capitalize/0. title/0. upper/0. lower/0. Strip (RM), One ALen/1, -Enumerate/1, -Zip/2, theisinstance/(Var,type), -Map/(FUN/1, list), -reduce/((fun/2+start?), list), -filter/(FUN/1, list), +sorted/(LIST,DIY_CMP_FUN/2), - +!defThe inner layer function refers to the parameters of the outer function, and then returns the case of the inner function, called the closure (Closure) A !ex! at defcalc_sum (LST): - deflazy_sum (): - returnsum (LST) - returnLazy_sum - !note! do not reference any of the loop variables, or any subsequent variables that will change - !dying! in defcount (): -FS = [] toL=range (1,4) + forIinchRange (1, 4): - defF (j): the defg (): * returnj*J $ returngPanax NotoginsengR=f (i) - Fs.append (R) the returnFS + AF1, F2, F3 =count () the PrintF1 (), F2 (), F3 ()
View all Note
Learn the list of slices, and found similar to Matlab, is very happy, because a bit of MATLAB foundation, so instant clearance, confidence surge.
Learn to generate the list expression, let me marvel, it expresses the way is very appropriate, easy to use, used to generate HTML, confidence again burst, because understand the point HTML tags, and a pass.
To the closure of the emotional complex, this thing can return to a specific function, although do not know what to use, but still feel very strong appearance. Be puzzled by the exercises, finally have a clue.
This involves a variety of pointers, learned C, so barely understand. Nearly collapsed, here the answer pressure yajing.
1 defcount ():2FS = []3L=range (1,4)4 forIinchRange (1, 4):5 defF (j):6 defg ():7 returnj*J8 returng9R=f (i)Ten Fs.append (R) One returnFS A -F1, F2, F3 =count () - PrintF1 (), F2 (), F3 ()
The topic is in the MU class net. Python advanced. Closures.
My understanding: The function F accepts J (i.e. I), creates a copy of J in its own memory, so that J is 1 or 2 or 3, it is fixed, and the returned G function is a 1x1 or 2x2 or 3x3,r f (i) equivalent to F (i), which differs from the original code, when I is closed to F, F can also return to the state at this time, so I again change also affect not to JXJ, this is probably called "Closure" bar. The function pointer is then incorporated into the list and passed to the outside of count to be eaten.
This is the first day, continue to refuel.
The first day of Python learning