python函数中def func(*args)这里*的作用是什么?
2个回答
引用可靠的我心我在的回答:
def fun_var_args(farg, *args): print "arg:", farg for value in args: print "another arg:", value fun_var_args(1, "two", 3) # *args可以当作可容纳多个变量组成的list
def fun_var_args(farg, *args): print "arg:", farg for value in args: print "another arg:", value fun_var_args(1, "two", 3) # *args可以当作可容纳多个变量组成的list
展开全部
*args是多个变量组成的元组(tuples)
附上代码:
def count_number(*args):
print(args)
print(type(args))
count_number('hgfh','dasda')
附上代码:
def count_number(*args):
print(args)
print(type(args))
count_number('hgfh','dasda')
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询