1、简介
Faker是一个为您生成假数据的python包。无论您需要引导数据库、创建美观的XML文档、填充持久性以对其进行压力测试,还是匿名化从生产服务中获取的数据,Faker都是为您服务的。
2、使用方法
from faker import Faker
#fake = Faker()#默认为英文
fake = Faker(locale='zh_CN')#切换为中文
print(fake.name()) #伪造名字
print(fake.address()) #伪造地址
print(fake.ssn()) #伪造身份证
print(fake.phone_number()) #伪造手机号
常用参数
fake.city() # 城市名称
North Karen
fake.street_name() # 街道名称
Lopez Dale
fake.country_code() # 国家编号
ML
fake.longitude() # 经度
109.213240
fake.address() # 地址
7927 Christopher Lake
Thomasmouth, ME 73174
fake.latitude() # 纬度
-79.2992145
fake.street_address() # 街道地址
7775 Jacob Wall Apt. 561
fake.city_suffix() # 市
view
fake.postcode() # 邮政编码
34098
fake.country() # 国家
Estonia
fake.street_suffix() # 街道后缀
River
fake.building_number() # 建筑编号
5330
fake.license_plate() # 车牌号
Q97 2BU
fake.rgb_css_color() #颜色RGB
rgb(220,140,229)
fake.safe_color_name() # 颜色名称
white
fake.company() # 公司名
Roberts, Bates and Parker
fake.credit_card_number(card_type=None) # 信用卡卡号
3568612931335293
fake.date_time(tzinfo=None) # 随机日期时间
1996-07-18 02:05:39
fake.file_extension(category=None) # 文件扩展信息
bmp
fake.ipv4(network=False) # ipv4地址
96.137.50.163
网友评论