Py学习  »  Python

python错误:“type”类型的“type error”参数不可iterable

gbenyu • 6 年前 • 1930 次点击  

我正在做一个学校项目,我必须生成一个没有重复的数字列表。扭曲是我不允许使用 random.sample() random.shuffle() . 我想我已经找到了一种方法来处理我的代码,除了我得到错误 TypeError "argument of type 'type' not iterable . 我没能避开这件事,所以我需要一些帮助。谢谢你的帮助 代码如下:

import random
lis=[]

for i in range(5):
    rand=random.randint(1,10)
    if rand not in list: lis.append(rand)

print (lis)
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/46118
文章 [ 3 ]  |  最新文章 6 年前