错误提示 错误原因 random.sample()里面没有使用list,而是set,所以只要我们做一个列表转换就可以成功 解决错误 for i in range(d.dataframe.shape[1]): random_sample = random.sample(list(feature_list[i]),20) print(random_sample,len(random_sample))