Python choice()函数参数:关键字arg后为非关键字arg
当我尝试运行它时,我得到错误:SyntaxError:non-keyword-arg-after-keyword-argPython choice()函数参数:关键字arg后为非关键字arg,python,random-sample,Python,Random Sample,当我尝试运行它时,我得到错误:SyntaxError:non-keyword-arg-after-keyword-arg 如何修复它?这里的weight\u list是一个非关键字参数。在Python中调用函数时,所有关键字参数(key=value-type)都应该跟在所有非关键字参数后面。您对选项的调用应如下所示: tup_list = [1,2,3,4,5] weight_list = [0.5,0.6,0.1,0.7] draw = choice(tup_list, sample_s
如何修复它?这里的
weight\u list
是一个非关键字参数。在Python中调用函数时,所有关键字参数(key=value-type)都应该跟在所有非关键字参数后面。您对选项的调用应如下所示:
tup_list = [1,2,3,4,5]
weight_list = [0.5,0.6,0.1,0.7]
draw = choice(tup_list, sample_size_d, replace=False, weight_list)
见这个问题:
这里的权重列表
是一个非关键字参数。在Python中调用函数时,所有关键字参数(key=value-type)都应该跟在所有非关键字参数后面。您对选项的调用应如下所示:
tup_list = [1,2,3,4,5]
weight_list = [0.5,0.6,0.1,0.7]
draw = choice(tup_list, sample_size_d, replace=False, weight_list)
见这个问题:
可能重复的可能重复的