码迷,mamicode.com
首页 > 编程语言 > 详细

python造数

时间:2018-05-06 21:18:06      阅读:409      评论:0      收藏:0      [点我收藏+]

标签:length   test   \n   from   ret   dom   char   open   数据   

做性能测试时,往往需要大量的参数化数据,比如注册。

from random import Random

def random_str(randomlength=8):
str=‘‘
chars=‘0123456789‘
length=len(chars) -1
random=Random()
for i in range(randomlength):
str+=chars[random.randint(0,length)]
return str

li=‘1‘

list=li.split(",")

fd2=open(r‘C:/0427/test.txt‘,"a+")
for i in range(1,50000):

random0=random_str()
list[0]=‘111‘+random0

 


list1=‘,‘.join(list)
fd2.writelines(list1)
fd2.writelines("\n")
fd2.flush()


print "sucess!"

 

python造数

标签:length   test   \n   from   ret   dom   char   open   数据   

原文地址:https://www.cnblogs.com/lanyy/p/8999489.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!