import random from tqdm import tqdm fp = open('./materials/id_back.txt', 'w+', encoding='utf-8') for i in tqdm(range(0, 1000)): num = random.randint(100000000, 9999999999) num_str = str(num).zfill(10) fp.write(num_str + '\n') fp.close()