python学习:函数
1 #!/usr/bin/env python 2 #coding:utf-8 3 4 def test1(): 5 "test1 ok" 6 print(' in the test1') 7 8 test1() 9 10 11 def test2(): 12 print('aa') 13 return 0 14 15 16 x=test2() 17 18 print(x) 19 20 21 def test3(): 22 return test2() 23 24 print(test3()) 25 26 #*参数组,接受N个位置参数,转换成元祖形式 27 #位置参数不能写在关键字参数后面 test4(x=1,3,4) 这样子是错误的 28 def test4(x,y,*args): 29 z=args[0] 30 31 print(z) 32 33 test4(1,2,3,4,y=2) 34 35 #**接受N个关键字参数转换成字典形式 36 def test5(**kwargs): 37 print(kwargs) 38 39 test5(name='alex',age=8)