faker庫生成資料

2021-10-17 23:15:49 字數 691 閱讀 6999

faker庫用於生成偽造的資料。

使用pip安裝

pip install faker
設定中文

from faker import faker

fk = faker(locale='zh_cn')

設定多語言

from faker import faker

fk = faker(locale=['zh_cn', 'en_us'])

#從faker模組匯入faker這個類。

from faker import faker

#例項化,儲存到變數fake中

#如果什麼也不傳入的話,就會生成英文

fake = faker("zh_tw")

# 呼叫phone_number()方法隨機生成乙個名字

print(fake.phone_number())

#呼叫address()方法隨機生成位址資訊

print(fake.address())

#呼叫company()方法隨機生成乙個公司

print(fake.company())

#呼叫date_time()方法隨機生成時間

print(fake.date_time())

參考文件

Python庫Faker 生成隨機測試資料

python庫 隨機生成測試資料的模組 pip install fakerin 2 from faker import faker fake faker 隨機生成乙個名字 fake.name out 2 timothy haynes in 3 from faker import factory fa...

自動生成資料庫字典

1.首先需要填寫表的每一列的說明 2.建立試圖 go object view dbo sura view dbdictionary script date 05 31 2013 17 19 19 set ansi nulls on goset quoted identifier on gocreat...

sessionFactory 生成資料庫表

tomcat 啟動時會讀取web.xml檔案 根據其中的配置 contextconfiglocation org.springframework.web.context.contextloaderlistener 1.首先讀取.中的配置資訊,建立contextloaderlistener 的例項物件...