标签:cte close hid .exe turn cat with lap print
1 def Result(a,*b): 2 result=0 3 result+=a 4 for x in b: 5 result+=x 6 return result 7 8 add_result=Result(1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39) 9 # add_result=Result(2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38) 10 print(add_result)
除此之外,在python的函数中我们传递的参数有些还有特殊的含义,比如def test(a,b,c=8,count=‘china‘)
1 # test2() 2 3 def Result(a,*b,**c): 4 print(a) 5 print(b) 6 print(c) 7 8 Result(1,3,5,7,11,13,15,17,19,21,23,25,27,31,33,35,37,f=29,t=9,g=39)
运行结果:
E:\Python35\python.exe F:/Exercise/Python/test0731/登陆.py
1
(3, 5, 7, 11, 13, 15, 17, 19, 21, 23, 25, 27, 31, 33, 35, 37)
{‘t‘: 9, ‘f‘: 29, ‘g‘: 39}
Process finished with exit code 0
备注:* 和**参数都是可传可不传递的,因此必须把必须要传的放在第一位,这个一定要切记。
标签:cte close hid .exe turn cat with lap print
原文地址:http://www.cnblogs.com/rourou1/p/6241232.html