懒羊羊softwaretesting

导航

python造数

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

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!"

 

posted on 2018-05-06 20:27  懒羊羊呐  阅读(237)  评论(0编辑  收藏  举报