from faker import Faker import os, random, gzip import re, time from pypinyin import pinyin, Style from datetime import datetime, timedelta from concurrent.futures.thread import ThreadPoolExecutor faker = Faker('zh_CN') def dir_exists(dir_path): """ 判断日期目录是否存在 :return: """ if not os.path.exists(dir_path): os.makedirs(dir_path) return dir_path def three_num(): data_list = [x for x in range(10)] data = random.sample(data_list, 3) return str(data[0]) + str(data[1]) + str(data[2]) def get_idd_code(): """ 随机选择国际长途电话区号 (非0开头,两位或者三位) :return: """ no_zero = [x for x in range(1, 10)] zero = [x for x in range(10)] num = random.randint(0, 1) if num == 0: # 生产两位国际区号 a = random.sample(no_zero, 2) return str(a[0]) + str(a[1]) else: # 生产三位国际区号 a = random.choice(no_zero) b = random.sample(zero, 2) return str(a) + str(b[0]) + str(b[1]) def gz_phone_file(file_path): """ 压缩个人电话信息数据文件 :param file_path: :return: """ gz_phone_file = re.findall(r'(.+?)\.', file_path)[0] + ".gz" with gzip.open(gz_phone_file, 'wb') as f_w: with open(file_path, "r", encoding="utf-8") as f_r: for line in f_r: f_w.write(bytes(line, encoding=&
模拟生成个人电话信息数据和个人基本信息数据
最新推荐文章于 2022-07-13 09:49:34 发布