1.函数只有被调用才能使用
2. 输入的参数名不能有重名,并且需要有RETURN 返回值
3.常用的函数打印描述:
print test2.__doc__
var.append('ddd');原来的基础上增加字符串
一: 函数参数是字典的形式(变量名与值)
>>> def test2(**z):return z
>>> print test2(a=1,b=2,c=3)
{'a': 1, 'c': 3, 'b': 2}
运行结果如下:
四:列表的形式返回
return z
>>> print test3(1,2,3)
(1, 2, 3)
二: 通常的做法位置参数,需要输入全部的参数
>>> def mytest(a,b,c):
return a + b + c
>>> mytest(1,2,3)
6
三:可选的参数: 需要定义值
>>> def test(a=3,b=4,c=5):
return a + b +c
>>> print test()
12
>>> print test(a=10)
19
>>>