#-*-Coding:utf-8-*- #utf-8 Support Chinese encoding words=[' cat ', ' dog ', ' chicken ']for W in words[:]: #words [:] Copied the original list Words.insert (0, w) Print Words a = Range (0,10,4) print Aargs=[3,10,3]print range (*args) #[3, 6, 9] #我们还可以把range的argument储存在list或tuple中 def F (A, l=[]): L.append (a) return l Print f (1) print F (2) print F (3) [1][1, 2][1, 2, 3] The default value of the function parameter is initialized only the first time, which is the static variable ' def A (a=0): a=a+1 Print A a () a () "But this shows only 1 because the Mutable object in Python is List,dictionary,instances" def AA (*args,**keys): for a in args: print a for D in keys: print D, ' : ', keys[d]   AA (1,2,3,a=1,b=2,c=3) #类似cpp的 *arg Plus * indicates that it will accept arbitrary arg,** to accept arbitrary dict def Parrot (Voltage, state= ' a stiff ', action= ' voom '): print "--this parrot wouldn ' t", action, &NB Sp Print "If you put", voltage, "volts through it.", &NBSp Print "E ' s", State, "!" d = {"state": "Bleedin ' demised", "Voltage": "Four Million", "Action": "Voom"}parrot (**d) #--this parrot would N ' t voom if you put the four million volts through it. E ' s bleedin ' demised! #我们可以把参数保存在字典中 if key is corresponding to argument. f=lambda a,b,c:a*b+cprint F (2,3,5) # Enter the previous argument, return the following value #字典树user ={}user[' CS ']={}user[2]={}user[' cs ' [' bo ']=1user[' CS ' [' Co ']=2user[2][1]= 1print User.keys () print user.values () print user[' CS '].values () print user[' CS '].keys ()
C + + to python knowledge of one of the little notes