从0~9中随机产生4个互不相等的数,
方法一:
import random s=[]
while(len(s)<4):
x=random.randint(0,9)
if x not in s:
s.append(x) print(s)
方法二:
import random result=[]
x=range(10) for i in range(4):
t=random.randint(i,9)
temp=x[i]
x[i]=x[t]
x[t]=temp
result.append(x[i]) print result