def Cola(I1,I2):
import random
c1 = []
c = []
b = 0
I3 = I1
I4 = I2-1
print('取', I1, sep='', end='')
print('位数')
print('取', I2, sep='', end='')
print('个数:', end='\n')
for I2 in range(0, I2):
d = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
c = []
for I1 in range(0, I1+1):
if I1 == I3:
break
if I1 == 0:
b = random.randrange(1, 9-I1)
else:
b = random.randrange(0, 9-I1)
c.append(d[b])
del d[b]
c1.append(int(''.join('%s' %i for i in c)))
return c1
a = Cola(5,5)
print(a)
用这种方法也有可能会取到相同的数,但是机率较小就忽略了