图1、2为pycharm 运行结果
图3是imooc的运行结果
# Enter a code
def infom(**kwargs):
names_list=kwargs['names']
gender_list=kwargs['gender']
age_list=kwargs['age']
index=0
for name in names_list:
gender=gender_list[index]
age=age_list[index]
print('name:{},gender:{},age:{}'.format(name,gender,age))
index=index+1
func(names=['赵','钱','孙','李'],gender=['male','male','female','male'],ages=[20,21,37,67])
是的,线上编译器,你需要将变量名和值同时当参数传过去才行
func(names=['赵','钱','孙','李'],gender=['male','male','male'],ages=[16,17,18])
可能是的,我在上一个章节也碰到一些问题
# -*- coding:utf-8 -*-def func(*args,**kwargs): for n in range(0,len(names)): name=names[n] gender=genders[n] age=ages[n] print('names:{},genders:{},ages:{}'.format(name,gender,age)) return names=['赵','钱','孙','李']genders=['male','male','female','male']ages=[20,21,37,67]func(names,genders,ages)