You can use itertools library. It has permutations, combinations operations. Look at the following example. Hope it helps.
>>> import itertools>>> import random>>> num_list=[]>>> n=15>>> t=list(itertools.permutations('123456789', 7))>>> for i in range(n):... idx=random.randint(1,len(t)-1)... k=''.join(str(e) for e in t[idx])... num_list.append(k)...>>> num_list['6127354', '5713894', '8342971', '1367458', '6729438', '6298317', '9758624', '5634821', '9457123', '3156498', '9158264', '9543786', '6892137', '7649382', '3289765']