关于Python-faker的函数效果一览


Posted in Python onNovember 28, 2019

tags faker 随机 虚拟

faker文档链接

代码程序:

# -*- coding=utf-8 -*-
import sys
from faker import Factory
reload(sys)
sys.setdefaultencoding('utf8')

fake = Factory().create('zh_CN')
li = dir(fake)
def get_dir_run():
  with open('somefile.txt', 'wt') as f:
    for i in li:
      a = None
      try:
        cmd = "fake."+i+"()"
        a = eval(cmd)
        print cmd
      except Exception:
        a = None
      if a:
        message = "{0}  # {1} \n".format(cmd,a)
        f.write(message)
get_dir_run()

函数样例:

fake.__class__()  # <faker.generator.Generator object at 0x7ff780c23e10> 
fake.__hash__()  # 8793824177497 
fake.__repr__()  # <faker.generator.Generator object at 0x7ff78c42d590> 
fake.__sizeof__()  # 32 
fake.__str__()  # <faker.generator.Generator object at 0x7ff78c42d590> 
fake.__subclasshook__()  # NotImplemented 
fake.address()  # 云南省荣县白云延路y座 648847 
fake.am_pm()  # AM 
fake.ascii_company_email()  # zhangchao@mao.com 
fake.ascii_email()  # yongzheng@hotmail.com 
fake.ascii_free_email()  # gongfang@hotmail.com 
fake.ascii_safe_email()  # tzhao@example.net 
fake.boolean()  # True 
fake.bothify()  # 10 Nq 
fake.bs()  # productize front-end supply-chains 
fake.building_number()  # E座 
fake.catch_phrase()  # Visionary logistical initiative 
fake.century()  # II 
fake.chrome()  # Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_8_9) AppleWebKit/5352 (KHTML, like Gecko) Chrome/14.0.828.0 Safari/5352 
fake.city()  # 成都市 
fake.city_name()  # 宁德 
fake.city_suffix()  # 市 
fake.color_name()  # DarkOliveGreen 
fake.company()  # 网新恒天信息有限公司 
fake.company_email()  # xiongchao@cai.com 
fake.company_prefix()  # 维旺明 
fake.company_suffix()  # 信息有限公司 
fake.country()  # 阿拉伯联合酋长国 
fake.country_code()  # ES 
fake.credit_card_expire()  # 06/22 
fake.credit_card_full()  # JCB 16 digit
柳 冉
3096337563919187 07/23
CVC: 610

fake.credit_card_number()  # 6011172478902092 
fake.credit_card_provider()  # Voyager 
fake.credit_card_security_code()  # 0753 
fake.cryptocurrency_code()  # XDN 
fake.currency_code()  # TWD 
fake.date()  # 1973-07-31 
fake.date_between()  # 2008-01-12 
fake.date_between_dates()  # 2017-12-06 
fake.date_object()  # 1972-08-01 
fake.date_this_century()  # 2008-09-16 
fake.date_this_decade()  # 2013-12-26 
fake.date_this_month()  # 2017-12-01 
fake.date_this_year()  # 2017-09-19 
fake.date_time()  # 2016-08-05 03:23:26 
fake.date_time_ad()  # 0258-04-07 20:48:11 
fake.date_time_between()  # 2006-06-09 01:28:22 
fake.date_time_between_dates()  # 2017-12-06 10:47:23 
fake.date_time_this_century()  # 2001-11-30 13:58:47 
fake.date_time_this_decade()  # 2012-08-25 18:04:34 
fake.date_time_this_month()  # 2017-12-04 11:24:57 
fake.date_time_this_year()  # 2017-06-02 08:50:48 
fake.day_of_month()  # 15 
fake.day_of_week()  # Thursday 
fake.district()  # 清河 
fake.domain_name()  # lu.com 
fake.domain_word()  # zhao 
fake.ean()  # 5954186746588 
fake.ean13()  # 9672235528133 
fake.ean8()  # 06171292 
fake.email()  # zhengtao@gmail.com 
fake.file_extension()  # docx 
fake.file_name()  # 品牌.doc 
fake.file_path()  # /关于/推荐.pptx 
fake.firefox()  # Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_7; rv:1.9.4.20) Gecko/2011-01-16 07:23:04 Firefox/5.0 
fake.first_name()  # 玉珍 
fake.first_name_female()  # 彬 
fake.first_name_male()  # 莹 
fake.first_romanized_name()  # Fang 
fake.free_email()  # bwen@hotmail.com 
fake.free_email_domain()  # yahoo.com 
fake.future_date()  # 2017-12-13 
fake.future_datetime()  # 2017-12-19 00:29:14 
fake.geo_coordinate()  # -172.459902 
fake.hex_color()  # #b4e7a9 
fake.image_url()  # https://dummyimage.com/517x471 
fake.internet_explorer()  # Mozilla/5.0 (compatible; MSIE 6.0; Windows CE; Trident/4.0) 
fake.ipv4()  # 6.155.240.182 
fake.ipv6()  # 6903:92c5:9e08:5f0c:5fda:b85e:97ec:b885 
fake.isbn10()  # 0-02-210237-X 
fake.isbn13()  # 978-1-79735-105-6 
fake.iso8601()  # 1986-08-09T07:49:59 
fake.job()  # Designer, graphic 
fake.language_code()  # bs 
fake.last_name()  # 逯 
fake.last_name_female()  # 申 
fake.last_name_male()  # 查 
fake.last_romanized_name()  # Dong 
fake.latitude()  # 10.6496555 
fake.lexify()  # PEdF 
fake.license_plate()  # 4-2558G 
fake.linux_platform_token()  # X11; Linux i686 
fake.linux_processor()  # i686 
fake.locale()  # ka_GE 
fake.longitude()  # -45.494435 
fake.mac_address()  # 70:0a:bf:0f:77:47 
fake.mac_platform_token()  # Macintosh; PPC Mac OS X 10_7_7 
fake.mac_processor()  # Intel 
fake.md5()  # 71f8c16a5f87000130b7df65611c364a 
fake.mime_type()  # message/partial 
fake.month()  # 11 
fake.month_name()  # February 
fake.msisdn()  # 6138497580204 
fake.name()  # 离莹 
fake.name_female()  # 万成 
fake.name_male()  # 况丽华 
fake.null_boolean()  # True 
fake.numerify()  # 877 
fake.opera()  # Opera/9.94.(Windows 95; nl-BE) Presto/2.9.171 Version/11.00 
fake.paragraph()  # 系列位置由于作品什么特别研究.精华网络或者搜索.主题我们类别这个增加. 
fake.paragraphs()  # [u'\u516c\u53f8\u9700\u8981\u65f6\u95f4\u73af\u5883.\u7684\u4eba\u63d0\u4f9b\u79ef\u5206\u5728\u7ebf\u6807\u51c6\u6cd5\u5f8b\u6211\u4eec\u6ce8\u610f.', u'\u8c22\u8c22\u57fa\u672c\u4ec0\u4e48\u4e2d\u6587\u540d\u79f0\u7136\u540e\u9996\u9875\u5de5\u5177.\u539f\u56e0\u6ca1\u6709\u9700\u8981\u8ba1\u5212\u5b9e\u73b0\u89c9\u5f97.\u7ed3\u679c\u5f53\u524d\u7814\u7a76\u5927\u5bb6.', u'\u7684\u8bdd\u90fd\u662f\u4e4b\u95f4\u4e3a\u4ec0\u672c\u7ad9\u89c4\u5b9a\u5927\u5b66.\u5206\u6790\u62e5\u6709\u800c\u4e14\u6587\u4ef6.'] 
fake.password()  # z@YJ7Wcpgv 
fake.past_date()  # 2017-11-22 
fake.past_datetime()  # 2017-12-03 18:08:05 
fake.phone_number()  # 18597001558 
fake.phonenumber_prefix()  # 132 
fake.postcode()  # 870942 
fake.profile()  # {'website': [u'https://www.hu.net/', u'https://www.zou.cn/', u'https://shen.cn/', u'http://kong.com/'], 'username': u'wanjing', 'name': u'\u79e6\u79c0\u5170', 'blood_group': '0+', 'residence': u'\u8fbd\u5b81\u7701\u5e06\u53bf\u79c0\u82f1\u516d\u76d8\u6c34\u8857u\u5ea7 436149', 'company': u'\u9ec4\u77f3\u91d1\u627f\u4fe1\u606f\u6709\u9650\u516c\u53f8', 'address': u'\u897f\u85cf\u81ea\u6cbb\u533a\u51e4\u5170\u53bf\u5c71\u4ead\u94f6\u5ddd\u8857P\u5ea7 346744', 'birthdate': '1985-04-28', 'sex': 'M', 'job': 'Engineer, mining', 'ssn': u'433125195206070070', 'current_location': (Decimal('-15.7126615'), Decimal('-143.411020')), 'mail': u'fliang@hotmail.com'} 
fake.province()  # 广西壮族自治区 
fake.pybool()  # True 
fake.pydecimal()  # 384.433560097 
fake.pydict()  # {u'\u5927\u5bb6': u'https://www.gao.net/categories/categories/index.php', u'\u90a3\u4e48': 4623, u'\u72b6\u6001': datetime.datetime(1994, 3, 19, 8, 6, 12), u'\u80fd\u529b': Decimal('6.96492'), u'\u540c\u65f6': u'JpjrByPDCgnsNDfaNYgd', u'\u5ba2\u6237': 3485} 
fake.pyfloat()  # -4099208226.9 
fake.pyint()  # 3270 
fake.pyiterable()  # [-7155.447707, u'KOQVBTsYxVpaVxpHBXiO', u'https://www.kang.com/index.php', u'jKmLqgUUOEqdXCeTGBID', u'pGVNjKcxmCTQNpdpKbgm', -48.1915257969, datetime.datetime(1975, 9, 27, 18, 22, 43)] 
fake.pylist()  # [4770, datetime.datetime(1990, 4, 11, 9, 59, 16), 2546, 8087, -612180.919, 2.3246212976] 
fake.pyset()  # set([u'uwFlxgSEwApkViCNpQZk', u'TlijxYEXankqWtWXkHax', u'TPgKtCtIHXIaKxgWMDjo', Decimal('-72118073288.1'), u'LYoqafrVUVggsnWJXKUg', Decimal('-239813.3099'), u'ELLFUOSNKtxYyhtCXPPg', 1371]) 
fake.pystr()  # GdxudJdOCeExecGzFpJg 
fake.pystruct()  # ([u'WTHzKZdDIrwhUfPHrjMb', u'MVXsSqDWyabyceZRSgGr', datetime.datetime(1993, 10, 3, 1, 1, 31), u'sKcZHJgAGVZrCIfIHwMS', 7694, u'wdedDezTMpfOxUQHaVlO', u'iMgUrRzaaYtArWrnxWda', u'tixihvoqNqQVByfEoGsg', u'https://www.qiu.com/search/explore/home.html', 898068606944.83], {u'\u6709\u9650': Decimal('4.3883198'), u'\u8fd9\u4e48': u'UVOyihAmcukcQJcVIOah', u'\u5408\u4f5c': 3743, u'\u4e0d\u540c': datetime.datetime(2005, 2, 23, 7, 35, 45), u'\u63d0\u9ad8': datetime.datetime(1987, 2, 10, 2, 28, 44), u'\u8bc4\u8bba': 8874, u'\u5173\u4e8e': u'apan@wei.net', u'\u7ec4\u7ec7': 468, u'\u60c5\u51b5': 6083, u'\u884c\u4e1a': u'qiang61@long.org'}, {u'\u4e13\u4e1a': {3: u'AkBWAoxmmokgNrRogyYk', 4: [4596, u'nJzscDjtYSbEzPdkOkRK', 5365], 5: {3: 4605, 4: u'chao87@wei.com', 5: [u'xia30@lu.cn', datetime.datetime(2006, 10, 25, 21, 37, 41)]}}, u'\u4e2d\u6587': {8: [u'oYYfArTznrMITieKBrdT', u'QoESvZcnaAZFmaQqjrgk', u'afkzJChqTNmwwcUXcTOu'], 9: {8: u'ughNWEsmKFFnPReWycbf', 9: [-6.41272, -39213.981], 7: u'RKIcxKTOThQLwaIgVFWe'}, 7: u'uIVZuDPnedhnOJVZUzfX'}, u'\u8fd8\u662f': {9: u'JqElYMJfaassiofLGvLn', 10: [4443, u'aZgiftVvonSEzCzTddiO', u'shaowei@yan.com'], 11: {9: 9967, 10: 5143, 11: [u'usmTtsPWPYtObuYObOpB', Decimal('-31192.5654601')]}}, u'\u6765\u81ea': {1: u'sIqUyGCneohdHGgznDuU', 2: [datetime.datetime(2007, 5, 31, 11, 24, 16), 8321, u'pfIJmDxwAquYLyxrpuVz'], 3: {1: u'gliang@hotmail.com', 2: Decimal('33965.0'), 3: [u'AexgPcuhOIziJhYifZtR', datetime.datetime(2003, 3, 24, 22, 28, 43)]}}, u'\u7cfb\u7edf': {4: u'welRgeLqhOQPGkdkviok', 5: [Decimal('-46.5'), u'hmJxbwRBLukmjHylLojM', u'http://www.mao.cn/search/tag/index.html'], 6: {4: u'http://zou.cn/tag/index/', 5: u'uBlLVOtLauDbAMlrpTZM', 6: [u'bqiHwnSArJdlQnvsbKPN', u'RQdmtWPMwiFuaThJrMWm']}}, u'\u6280\u672f': {8: 2626, 9: [Decimal('4719860282.19'), Decimal('-392046163.17'), datetime.datetime(2005, 1, 11, 13, 21, 2)], 10: {8: u'MoUiPqxBcSTrkudFLIza', 9: u'XUQtWQGntEeuayziAnYA', 10: [u'ulhMPZKMdlQzfWdUuYIF', datetime.datetime(1994, 7, 25, 9, 15, 28)]}}, u'\u9009\u62e9': {8: {8: [u'yong58@ren.cn', u'cGFuWyLdFRUzGhTCaFjE'], 6: 7701, 7: datetime.datetime(2010, 8, 15, 10, 6, 13)}, 6: u'zengwei@gmail.com', 7: [6858, 6403, datetime.datetime(1984, 4, 18, 11, 0, 12)]}, u'\u4e00\u70b9': {0: 6620, 1: [u'OrTScuyESDqszlQjOlYX', u'hJahyMWdkPLhNOMzrdfy', u'mmZYqEDMYPodgUuICyct'], 2: {0: -33313798379.385, 1: u'XRpLoRsRMQIROsBqIHlG', 2: [u'xZozzLqTMwXpfdTpMscc', u'https://www.xia.com/']}}, u'\u7531\u4e8e': {2: u'naguo@qian.com', 3: [u'wTVRQMbwJPUNAKbhAKFs', Decimal('-679732200.8'), u'braeyLsfMvOtsSrgwlxX'], 4: {2: u'feviQSXEPjAzICRiXIWU', 3: u'xiuyinghe@gmail.com', 4: [5961281603639.0, u'YNOuECSZEExtHvlGKwwE']}}, u'\u56fe\u7247': {5: datetime.datetime(1977, 3, 29, 23, 38), 6: [u'http://yin.com/main.jsp', u'yanjia@yahoo.com', 632.53909299766], 7: {5: u'RqBzkDuehAQUCHYQCmAZ', 6: 4597, 7: [8421, 7708]}}}) 
fake.pytuple()  # (u'CJFHMwspGSwiPKfZhCVY', u'IDhxTOsuOiDHOlKtMbbe', 6637, 978, u'RodatDSuaRbwlgTJNzKx', u'fsUVemSiAyPqyLFmfdZD', u'zhujuan@li.cn', u'https://kong.cn/categories/app/login.htm', Decimal('-406039.250589'), 8127) 
fake.random_digit()  # 9 
fake.random_digit_not_null()  # 6 
fake.random_digit_not_null_or_empty()  # 5 
fake.random_digit_or_empty()  # 3 
fake.random_element()  # a 
fake.random_int()  # 4585 
fake.random_letter()  # o 
fake.random_number()  # 80709883 
fake.random_sample()  # ['a', 'c'] 
fake.random_sample_unique()  # set(['a', 'c', 'b']) 
fake.randomize_nb_elements()  # 13 
fake.rgb_color()  # 97,134,130 
fake.rgb_css_color()  # rgb(39,226,180) 
fake.romanized_name()  # Qiang Du 
fake.safari()  # Mozilla/5.0 (Windows; U; Windows NT 6.0) AppleWebKit/532.2.5 (KHTML, like Gecko) Version/4.0.2 Safari/532.2.5 
fake.safe_color_name()  # yellow 
fake.safe_email()  # ming14@example.net 
fake.safe_hex_color()  # #ff3300 
fake.sentence()  # 方法科技是否只有无法. 
fake.sentences()  # [u'\u4ec0\u4e48\u672c\u7ad9\u6280\u672f\u4e00\u6b21\u8868\u793a\u4e0d\u540c\u5904\u7406.', u'\u8fd0\u884c\u65b9\u5f0f\u80fd\u529b\u4e00\u6837\u5f53\u524d.', u'\u6700\u65b0\u901a\u8fc7\u4e00\u4e2a\u5b66\u6821\u5f53\u524d\u4eca\u5e74\u5982\u679c\u5efa\u8bbe.'] 
fake.sha1()  # 7052c75358562302ddacd77e14e49986926374fa 
fake.sha256()  # 27e24e47230c764507a2e54d25a495e2f1f24ebcc23c6bf2b213b21379f8865e 
fake.simple_profile()  # {'username': u'nayuan', 'name': u'\u5b87\u9633', 'birthdate': '1975-11-12', 'sex': 'M', 'address': u'\u6c5f\u897f\u7701\u6f5c\u6c5f\u53bf\u6c38\u5ddd\u62d3\u8defj\u5ea7 699193', 'mail': u'guiying19@hotmail.com'} 
fake.ssn()  # 410403194106288547 
fake.street_address()  # 燕街L座 
fake.street_name()  # 广州街 
fake.street_suffix()  # 路 
fake.text()  # 留言大小看到.成为控制拥有.
电子个人产品产品这么其他文章.国际谢谢公司系统为什.一起其他作品客户一种系列.
事情中国记者.男人为什组织的话.
要求部门希望.很多投资深圳方面操作威望需要.
注意你们这种学生可是所有通过基本.游戏时候日本目前数据生活得到.
市场这是还是学校时间最后.关于之后浏览相关企业支持结果类别.正在专业人员实现. 
fake.time()  # 17:02:29 
fake.time_delta()  # 8837 days, 21:54:15 
fake.time_object()  # 03:34:28 
fake.time_series()  # <generator object time_series at 0x7ff7800cb280> 
fake.timezone()  # Asia/Jerusalem 
fake.tld()  # cn 
fake.unix_time()  # 1100321594 
fake.uri()  # https://pan.org/terms/ 
fake.uri_extension()  # .php 
fake.uri_page()  # login 
fake.uri_path()  # app/category 
fake.url()  # http://www.xie.com/ 
fake.user_agent()  # Mozilla/5.0 (Macintosh; Intel Mac OS X 10_5_6; rv:1.9.5.20) Gecko/2016-10-29 04:38:17 Firefox/12.0 
fake.user_name()  # jingmo 
fake.uuid4()  # f64bcfad-67c4-c748-5e19-86a74848e6fa 
fake.windows_platform_token()  # Windows NT 5.2 
fake.word()  # 更新 
fake.words()  # [u'\u7136\u540e', u'\u5927\u5b66', u'\u7a0b\u5e8f'] 
fake.year()  # 2001

以上这篇关于Python-faker的函数效果一览就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
Python用户推荐系统曼哈顿算法实现完整代码
Dec 01 Python
numpy数组拼接简单示例
Dec 15 Python
python实现多线程行情抓取工具的方法
Feb 28 Python
python 3.6.5 安装配置方法图文教程
Sep 18 Python
Python中flatten( )函数及函数用法详解
Nov 02 Python
对Python生成汉字字库文字,以及转换为文字图片的实例详解
Jan 29 Python
对python 自定义协议的方法详解
Feb 13 Python
Python基础学习之类与实例基本用法与注意事项详解
Jun 17 Python
Python使用QQ邮箱发送邮件报错smtplib.SMTPAuthenticationError
Dec 20 Python
Python模块常用四种安装方式
Oct 20 Python
python基于openpyxl生成excel文件
Dec 23 Python
用PYTHON去计算88键钢琴的琴键频率和音高
Apr 10 Python
python 监测内存和cpu的使用率实例
Nov 28 #Python
python随机生成库faker库api实例详解
Nov 28 #Python
python的faker库用法
Nov 28 #Python
关于python中plt.hist参数的使用详解
Nov 28 #Python
python创建子类的方法分析
Nov 28 #Python
python 实现快速生成连续、随机字母列表
Nov 28 #Python
Python操作多维数组输出和矩阵运算示例
Nov 28 #Python
You might like
php array_search() 函数使用
2010/04/13 PHP
PHP使用GIFEncoder类处理gif图片实例
2014/07/01 PHP
php中JSON的使用方法
2015/04/30 PHP
Laravel 5.1 on SAE环境开发教程【附项目demo源码】
2016/10/09 PHP
Ubuntu 16.04下安装PHP 7过程详解
2017/03/28 PHP
Jquery练习之表单验证实现代码
2010/12/14 Javascript
当前流行的JavaScript代码风格指南
2014/09/10 Javascript
node.js中的buffer.write方法使用说明
2014/12/10 Javascript
原生JS实现图片无缝滚动方法(附带封装的运动框架)
2017/10/01 Javascript
jQuery实现鼠标移到某个对象时弹出显示层功能
2018/08/23 jQuery
解决vue2.0路由跳转未匹配相应用路由避免出现空白页面的问题
2018/08/24 Javascript
js中的数组对象排序分析
2018/12/11 Javascript
关于vue状态过渡transition不起作用的原因解决
2019/04/09 Javascript
深度了解vue.js中hooks的相关知识
2019/06/14 Javascript
python获取文件扩展名的方法
2015/07/06 Python
python 循环while和for in简单实例
2016/08/16 Python
Python 快速实现CLI 应用程序的脚手架
2017/12/05 Python
Python使用正则表达式获取网页中所需要的信息
2018/01/29 Python
python爬取淘宝商品详情页数据
2018/02/23 Python
Python实现自定义顺序、排列写入数据到Excel的方法
2018/04/23 Python
Python利用字典破解WIFI密码的方法
2019/02/27 Python
Django 外键的使用方法详解
2019/07/19 Python
Python中正反斜杠(‘/’和‘\’)的意义与用法
2019/08/12 Python
Matplotlib配色之Colormap详解
2021/01/05 Python
使用canvas压缩图片上传的方法示例
2020/02/07 HTML / CSS
苹果香港官方商城:Apple香港
2016/09/14 全球购物
.NET面试问题集
2015/12/08 面试题
运动会入场式解说词
2014/02/18 职场文书
毕业生就业推荐表自我鉴定
2014/03/20 职场文书
《风筝》教学反思
2014/04/10 职场文书
2014年技术部工作总结
2014/12/12 职场文书
汇报材料怎么写
2014/12/30 职场文书
幼儿园安全工作总结2015
2015/04/20 职场文书
2015年端午节活动方案
2015/05/05 职场文书
Python selenium模拟网页点击爬虫交管12123违章数据
2021/05/26 Python
Python中异常处理用法
2021/11/27 Python