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)
当我尝试运行它时,我收到错误:SyntaxError:关键字arg之后的非关键字arg 我怎么能解决它?
答案 0 :(得分:0)
此处weight_list
是非关键字arg。在Python中调用函数时,所有关键字参数(key = value type)都应遵循所有非关键字参数。您拨打choice
的电话应该是:
draw = choice(tup_list, sample_size_d, weight_list, replace=False)