安装了好几次VS CODE,每次配置都有问题,照着各类大神的配置,还是不成功,中午终于搞定了。
参数被用在函数内部时,*可以将一组可变数量的参数合成参数值的元组。**将参数收集到一个字典中,参数的名字是字典的键,对应参数的值是字典的值
def foo(x,y,z,*args,**kargs): print('x =:',x) print('y = ',y) print ('z = ',z) print ('args = ',args) print(m in args) if args != () : print('It is a test') print(args[0]) print (kargs) m = 'nnp' print('Fisrt print') foo('qiwsir',2,"python") print('second print') foo(1,2,3,4,5,6,7,8) print('third print') foo(1,2,3,'nnp',5,name="qiwsir",day="sde",week='good')
Fisrt print x =: qiwsir y = 2 z = python args = () False {} second print x =: 1 y = 2 z = 3 args = (4, 5, 6, 7, 8) False It is a test 4 {} third print x =: 1 y = 2 z = 3 args = ('nnp', 5) True It is a test nnp {'name': 'qiwsir', 'day': 'sde', 'week': 'good'}