python中函数的参数
1、
>>> def a(x): ## 单个参数
print(x,"and xiao ming are good friends!")
>>> a()
Traceback (most recent call last):
File "<pyshell#476>", line 1, in <module>
a()
TypeError: a() missing 1 required positional argument: 'x'
>>> a(x = "xiao qiang")
xiao qiang and xiao ming are good friends!
2、
>>> def a(x,y): ## 两个参数
print(x * y)
>>> a()
Traceback (most recent call last):
File "<pyshell#481>", line 1, in <module>
a()
TypeError: a() missing 2 required positional arguments: 'x' and 'y'
>>> a(x = 5, y = 9)
45
>>>
3、
>>> def a(x,y,z): ## 三个参数
print(x * y / z)
>>> a()
Traceback (most recent call last):
File "<pyshell#486>", line 1, in <module>
a()
TypeError: a() missing 3 required positional arguments: 'x', 'y', and 'z'
>>> a(x = 5, y = 8, z = 3)
13.333333333333334