Python review(1)
1.Inside of a function , you can define a variable with key-wordglobal , just the same as C and Java
2.There is huge diffirence between print("there is &d men",num) andprint("there is &d men"%num) , the latter one is what python exactly need. Besides,the form of print("......",end
= '*') is useful."*"can be replaced by anything.
3.A function could embed into another function,then happened something interesting . The parameters of external one could be used by the internal one.This structure(or grammer) called closure ,too.
4.If we want to use a variable that defined in another function,it could be illegal.
5.Recursive algorithm is powerful,it's convenient,but beyond control.Get used to it , and pay enough attention ! Especially the initial condition and the end condition.
6.A sequence in { } could be a set , if we didn't set the key-value .
7.Several approaches to initialize a dictionary.Attention : if initialize a dictionary with function dict( ) , the left char or string (key) of '=' can't include ' ' . otherwise, if initialize
it just in { }, key must content ' ' and replace '=' with ' : '
8.summary: global closure lambda filter dictionary set frozenset

浙公网安备 33010602011771号