# 定义一个不重复的列表 import random list= [] count= 0 # 成功放入的次数 while count<5: num= random.randint(1,10) if num not in list: list.append(num) count+=1 # 成功后计数一次 print(list)