使用faker生成測試數據

需要先安裝faker模塊,pip install faker

導入模塊中的Faker類:from?faker?import?Faker

實例化faker = Faker()

print('姓名相關')
print('姓名:',faker.name())
print('名:',faker.first_name())
print('姓:',faker.last_name())
print('男姓名:',faker.name_male())
print('男名:',faker.first_name_male())
print('男姓:',faker.last_name_male())
print('女姓名:',faker.name_female())
print('女名:',faker.first_name_female())
print('女姓:',faker.last_name_female())
print('羅馬姓名:',faker.romanized_name())
print('羅馬名:',faker.first_romanized_name())
print('羅馬姓:',faker.last_romanized_name())

?

print('地址相關')
print('完整地址:',faker.address())
print('國家:',faker.country())
print('省份:',faker.province())
print('市:',faker.city_name())
print('縣或縣級市:',faker.city())
print('市或縣:',faker.city_suffix())
print('區域:',faker.district())
print('街道地址:',faker.street_address())
print('街道名稱:',faker.street_name())
print('街或路:',faker.street_suffix())
print('樓:',faker.building_number())
print('郵政編碼:',faker.postcode())

?

print('地理位置相關')
print('經緯度:',faker.latlng())
print('緯度:',faker.latitude())
print('經度:',faker.longitude())
print('未知:',faker.coordinate(center=None, radius=0.001))
print('未知:',faker.local_latlng(country_code="US", coords_only=False))
print('未知:',faker.location_on_land(coords_only=False))

?

print('公司相關')
print('公司全稱:',faker.company())
print('公司名稱:',faker.company_prefix())
print('公司性質:',faker.company_suffix())
print('未知:',faker.bs())
print('未知:',faker.catch_phrase())

?

print('職業相關')
print('職業:',faker.job())

?

print('顏色相關')
print('名稱表示法:',faker.color_name())
print('名稱表示法:',faker.safe_color_name())
print('rgb表示法:',faker.rgb_color())
print('rgb表示法:',faker.rgb_css_color())
print('十六進制表示法:',faker.hex_color())
print('十六進制表示法:',faker.safe_hex_color())

?

print('互聯網相關的數據,包括隨機電子郵箱、域名、IP 地址、URL、用戶名、后綴名等')
print('郵箱:',faker.email())
print('郵箱:',faker.safe_email())
print('郵箱:',faker.free_email())
print('郵箱:',faker.ascii_company_email())
print('郵箱:',faker.ascii_email())
print('郵箱:',faker.ascii_free_email())
print('example安全郵箱:',faker.ascii_safe_email())
print('郵箱:',faker.company_email())print('url:',faker.url(schemes=None))
print('圖片url:',faker.image_url(width=None, height=None))
print('uri:',faker.uri())
print('uri:',faker.uri_extension())
print('uri:',faker.uri_page())
print('uri:',faker.uri_path())print('域名全稱:',faker.domain_name(levels=1))
print('域名:',faker.domain_word())print('ipv4地址:',faker.ipv4(network=False, address_class=None, private=None))
print('ipv4地址類別:',faker.ipv4_network_class())
print('保留ipv4:',faker.ipv4_private(network=False, address_class=None))
print('公用ipv4:',faker.ipv4_public(network=False, address_class=None))
print('ipv6地址:',faker.ipv6(network=False))
print('mac地址:',faker.mac_address())print('主機名:',faker.hostname())

?

print('文件相關')
print('文件全稱:',faker.file_name(category=None, extension=None))
print('絕對路徑下文件全稱:',faker.file_path(depth=1, category=None, extension=None))
print('文件擴展名:',faker.file_extension(category=None))
print('未知:',faker.mime_type(category=None))
print('unix設備:',faker.unix_device(prefix=None))
print('unix分區:',faker.unix_partition(prefix=None))

?

print('常見數據類型')
print('布爾值:',faker.pybool())
print('整數:',faker.pyint(min_value=0, max_value=9999, step=10))print('decimal小數:',faker.pydecimal())
print('decimal小數定制:',faker.pydecimal(left_digits=None, right_digits=None, positive=False,min_value=None, max_value=None))
print('float小數:',faker.pyfloat())
print('float小數定制:',faker.pyfloat(left_digits=None, right_digits=None, positive=False,min_value=None, max_value=None))print('字符串:',faker.pystr(min_chars=None, max_chars=20))
print('列表:',faker.pylist(nb_elements=10, variable_nb_elements=True))
print('元組:',faker.pytuple(nb_elements=10, variable_nb_elements=True))
print('字典:',faker.pydict(nb_elements=10, variable_nb_elements=True))
print('集合:',faker.pyset(nb_elements=10, variable_nb_elements=True))

?

print('身份證號:',faker.ssn(dob=None, gender=None))

?

?

更多其他使用請參考https://mp.weixin.qq.com/s?__biz=MzU5MjEwMTE2OQ==&mid=2247487866&idx=1&sn=dd234bfbe9e54141709c063557bcfbb5&chksm=fe25bb24c952323297968e66966724e704b072e6c25cbe8b656bd02d0b05129969c71d73b5a5&mpshare=1&scene=23&srcid=0812Rorkp3n1cIlGxX0mj3Wc&sharer_sharetime=1565578020969&sharer_shareid=6a1e7ff5d0efc671db816475181c239c#rd

?

https://www.jianshu.com/p/6bd6869631d9

?

轉載于:https://www.cnblogs.com/Forever77/p/11338446.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/391744.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/391744.shtml
英文地址,請注明出處:http://en.pswp.cn/news/391744.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

JavaScript中的數組創建

JavaScript中的數組創建 本文轉載自:眾成翻譯 譯者:loveky 鏈接:http://www.zcfy.cc/article/713 原文:http://rainsoft.io/power-up-the-array-creation-in-javascript/ 數組是一個包含了對象或原始類型的有序集合。很難想象一個…

CODEVS——T1519 過路費

http://codevs.cn/problem/1519/ 時間限制: 1 s空間限制: 256000 KB題目等級 : 大師 Master題解查看運行結果題目描述 Description在某個遙遠的國家里,有 n個城市。編號為 1,2,3,…,n。這個國家的政府修建了m 條雙向道路,每條道路連接著兩個城市。政府規…

pca數學推導_PCA背后的統計和數學概念

pca數學推導As I promised in the previous article, Principal Component Analysis (PCA) with Scikit-learn, today, I’ll discuss the mathematics behind the principal component analysis by manually executing the algorithm using the powerful numpy and pandas lib…

pandas之cut

cut( )用來把一組數據分割成離散的區間。 cut(x, bins, rightTrue, labelsNone, retbinsFalse, precision3, include_lowestFalse, duplicatesraise) # x:被切分的數據,必須是一維的 # bins:①int型整數:將x按照數值大小平均分成分…

為Tueri.io構建React圖像優化組件

Let’s face it, image optimization is hard. We want to make it effortless.面對現實吧,圖像優化非常困難。 我們希望毫不費力。 When we set out to build our React Component there were a few problems we wanted to solve:當我們開始構建React組件時&#…

紅黑樹分析

紅黑樹的性質: 性質1:每個節點要么是黑色,要么是紅色。 性質2:根節點是黑色。性質3:每個葉子節點(NIL)是黑色。性質4:每個紅色節點的兩個子節點一定都是黑色。不能有兩個紅色節點相…

overlay 如何實現跨主機通信?- 每天5分鐘玩轉 Docker 容器技術(52)

上一節我們在 host1 中運行了容器 bbox1,今天將詳細討論 overlay 網絡跨主機通信的原理。 在 host2 中運行容器 bbox2: bbox2 IP 為 10.0.0.3,可以直接 ping bbox1: 可見 overlay 網絡中的容器可以直接通信,同時 docke…

第 132 章 Example

這里介紹一個負載均衡放置問題,我們可以把它擺放在任何位置,每種方案都各有優缺點,需要根據你的實際情況選擇使用 適用于HAProxy / Nginx / LVS 等等 這里用web,db為例子,講述負載均衡之間的關系 132.1. 雙負載均衡的用法 User --…

Python:實現圖片裁剪的兩種方式——Pillow和OpenCV

原文:https://blog.csdn.net/hfutdog/article/details/82351549 在這篇文章里我們聊一下Python實現圖片裁剪的兩種方式,一種利用了Pillow,還有一種利用了OpenCV。兩種方式都需要簡單的幾行代碼,這可能也就是現在Python那么流行的原…

第一個應在JavaScript數組的最后

by Thomas Barrasso由Thomas Barrasso 第一個應在JavaScript數組的最后 (The first shall be last with JavaScript arrays) So the last shall be [0], and the first [length — 1].所以最后一個應該是[0] ,第一個[length_1]。 – Adapted from Matthew 20:16–根…

鼠標移動到ul圖片會擺動_我們可以從擺動時序分析中學到的三件事

鼠標移動到ul圖片會擺動An opportunity for a new kind of analysis of Major League Baseball data may be upon us soon. Here’s how we can prepare.不久之后,我們將有機會對美國職棒大聯盟數據進行新的分析。 這是我們準備的方法。 It is tempting to think t…

leetcode 1052. 愛生氣的書店老板(滑動窗口)

今天,書店老板有一家店打算試營業 customers.length 分鐘。每分鐘都有一些顧客(customers[i])會進入書店,所有這些顧客都會在那一分鐘結束后離開。 在某些時候,書店老板會生氣。 如果書店老板在第 i 分鐘生氣&#xf…

回到網易后開源APM技術選型與實戰

篇幅一:APM基礎篇\\1、什么是APM?\\APM,全稱:Application Performance Management ,目前市面的系統基本都是參考Google的Dapper(大規模分布式系統的跟蹤系統)來做的,翻譯傳送門《google的Dappe…

持續集成持續部署持續交付_如何開始進行持續集成

持續集成持續部署持續交付Everything you need to know to get started with continuous integration: branching strategies, tests automation, tools and best practices.開始進行持續集成所需的一切:分支策略,測試自動化,工具和最佳實踐。…

51nod 1073約瑟夫環

思路傳送門 &#xff1a;http://blog.csdn.net/kk303/article/details/9629329 n里面挑選m個 可以遞推從n-1里面挑m個 然后n-1里面的x 可以轉換成 n里面的x 的公式 x &#xff08;xm&#xff09;%n; #include <bits/stdc.h> using namespace std;int main () {int n,m;s…

如何選擇優化算法遺傳算法_用遺傳算法優化垃圾收集策略

如何選擇優化算法遺傳算法Genetic Algorithms are a family of optimisation techniques that loosely resemble evolutionary processes in nature. It may be a crude analogy, but if you squint your eyes, Darwin’s Natural Selection does roughly resemble an optimisa…

robot:截圖關鍵字

參考&#xff1a; https://www.cnblogs.com/hong-fithing/p/9656221.html--python https://blog.csdn.net/weixin_43156282/article/details/87350309--robot https://blog.csdn.net/xiongzaiabc/article/details/82912280--截圖指定區域 轉載于:https://www.cnblogs.com/gcgc/…

leetcode 832. 翻轉圖像

給定一個二進制矩陣 A&#xff0c;我們想先水平翻轉圖像&#xff0c;然后反轉圖像并返回結果。 水平翻轉圖片就是將圖片的每一行都進行翻轉&#xff0c;即逆序。例如&#xff0c;水平翻轉 [1, 1, 0] 的結果是 [0, 1, 1]。 反轉圖片的意思是圖片中的 0 全部被 1 替換&#xff…

SVN服務備份操作步驟

SVN服務備份操作步驟1、準備源服務器和目標服務器源服務器&#xff1a;192.168.1.250目標服務器&#xff1a;192.168.1.251 root/rootroot 2、對目標服務器&#xff08;251&#xff09;裝SVN服務器&#xff0c; 腳本如下&#xff1a;yum install subversion 3、創建一個新的倉庫…

SpringCloud入門(一)

1. 系統架構演變概述 #mermaid-svg-F8dvnEDl6rEgSP97 .label{font-family:trebuchet ms, verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-F8dvnEDl6rEgSP97 .label text{fill:#333}#mermaid-svg-F8dvnEDl6rEgSP97 .node rect,#merm…