���� Python �̳� | ��7�� ���� | |
---|---|---|
��һҳ | �ؼ����� | ��һҳ |
������ij���������������������ֻ��ָ�����е�һ���֣���ô�����ͨ��������Ϊ��Щ������ֵ�����ⱻ���� �ؼ����� ��������ʹ�����֣��ؼ��֣�������λ�ã�����ǰ����һֱʹ�õķ�������������ָ��ʵ�Ρ�
������������ ���� ����һ���������Dz��ص��IJ�����˳��ʹ�ú�����ø��Ӽ��ˡ���������������������Ĭ��ֵ�����ǿ���ֻ��������Ҫ����Щ������ֵ��
#!/usr/bin/python
# Filename: func_key.py
def
func
(a, b=
5
, c=
10
):
print
'a is'
, a,
'and b is'
, b,
'and c is'
, c
func(
3
,
7
)
func(
25
, c=
24
)
func(c=
50
, a=
100
)
��Դ�ļ���code/func_key.py��
$ python func_key.py
a is 3 and b is 7 and c is 10
a is 25 and b is 5 and c is 24
a is 100 and b is 5 and c is 50
��Ϊfunc
�ĺ�����һ��û��Ĭ��ֵ�IJ�������������Ĭ��ֵ�IJ�����
�ڵ�һ��ʹ�ú�����ʱ�� func(3, 7)
������a
�õ�ֵ3
������b
�õ�ֵ7
��������c
ʹ��Ĭ��ֵ10
��
�ڵڶ���ʹ�ú���func(25, c=24)
��ʱ����ʵ�ε�λ�ñ���a
�õ�ֵ25
���������������ؼ�����������c
�õ�ֵ24
������b
����Ĭ��ֵ��Ϊ5
��
�ڵ�����ʹ��func(c=50, a=100)
��ʱ������ʹ�ùؼ���������ȫָ������ֵ��ע�⣬���ܺ��������У�a
��c
֮ǰ���壬������Ȼ������a
֮ǰָ������c
��ֵ��
��һҳ | ��һ�� | ��һҳ |
---|---|---|
Ĭ�ϲ���ֵ | ��ҳ | return��� |