Python 函数参数传递

#!/usr/bin/python
# -*- coding: UTF-8 -*-
#函数传值的问题

def foo(x,y=2,*tars,**dargs):
    print ('x=',x)
    print ('y=',y)
    print ('tars=',tars)
    print ('dargs',dargs)

调用结果展示


 结论:

*tars :适合于不确定参数个数的

**drags:必须接收类似arg=val形式参数

猜你喜欢

转载自blog.csdn.net/u013250424/article/details/80352316
今日推荐