1.安装依赖
pip install Faker -i https://pypi.tuna.tsinghua.edu.cn/simple
2.使用模块生成
from faker import Faker def produce_data(): fake = Faker(locale='zh_CN') # 账号 user_name = fake.user_name() # 身份证 ssn = fake.ssn(min_age=18, max_age=90) # 名字 name = fake.name() # 手机号 phone_number = fake.phone_number() # 车牌 plate = fake.license_plate() # 地址 address = fake.address() # 楼名 building_number = fake.building_number() # 国家 country = fake.country() # 生日 birth = fake.date_of_birth(tzinfo=None, minimum_age=0, maximum_age=115) # 公司 company = fake.company() # 职位 job = fake.job() # 信用卡号 card_number = fake.credit_card_number(card_type=None) # 城市 city = fake.city() # 星期 week = fake.day_of_week() # 邮件 email = fake.ascii_free_email() # 单句 sentence = fake.sentence(nb_words=6, variable_nb_words=True, ext_word_list=None) # 段落 paragraphs = fake.paragraphs(nb=3, ext_word_list=None) print(user_name,ssn, name, phone_number, plate, address, building_number, country, birth, company, job, card_number, city, week, email, sentence, paragraphs)
标签:None,name,Python,age,number,生成,fake,数据,card From: https://www.cnblogs.com/geogre123/p/16810481.html