python模块学习系列之创建测试数据(forgeryPy)

python admin 64℃ 0评论

安装forgeryPy模块

pip install ForgeryPy

测试代码

# -*- coding: utf-8 -*-
from random import seed
import forgery_py
import sys

reload(sys)  
sys.setdefaultencoding('utf8')



def generateLine():
    email=forgery_py.internet.email_address()
    username=forgery_py.internet.user_name(True)
    password=forgery_py.lorem_ipsum.word()
    name=forgery_py.name.full_name()
    location=forgery_py.address.city()
    # about_me=forgery_py.lorem_ipsum.sentence()
    member_since=forgery_py.date.date(True)
    line="{email} {username} {password} {name} {location} {member_since}" .format (
        email=email,username=username,password=password,name=name,location=location,
        member_since=member_since
    )
    return str(line)

def makeData(count=10):
    while(count>0):
        line=generateLine()
        print line
        count=count-1

makeData(1000)
# generateLine()

 

转载请注明:朋克网 » python模块学习系列之创建测试数据(forgeryPy)

喜欢 (0)
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址