Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python choice()函数参数:关键字arg后为非关键字arg_Python_Random Sample - Fatal编程技术网

Python choice()函数参数:关键字arg后为非关键字arg

Python 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

当我尝试运行它时,我得到错误: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_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)
见这个问题:

可能重复的可能重复的