性能测试之手机号码python生成方式

1、随机生成
吴老师写法
光荣之路吴老


def Mode():
    number_list = []
    count = 0
    while count <= 10000:
        number = str(random.randint(136, 139)) + str(random.randint(10000000, 99999999))
        if number not in number_list:
            number_list.append(number)
            count += 1
    fp = open("phone.dat", "w")
    for num in number_list:
        fp.write(num + "\n")
    fp.close()

结果:
13661725755
13977011577
13642512136
13970586384
2、顺序增加手机号

    Mobile = []
    for i in range(90000000000,90000000100,1):
        Mobile.append(i)
    #print Mobile
    fp = open("./dome01/phone.dat","w")
    for i in Mobile:
      fp.write(str(i) + "\n")
    fp.close()
    print("写文件")

90000000000
90000000001
90000000002
90000000003
90000000004
90000000005
90000000006










本文转自 知止内明 51CTO博客,原文链接:http://blog.51cto.com/357712148/2055687,如需转载请自行联系原作者
上一篇:Python快速学习03:运算 & 缩进和选择


下一篇:Python全栈 Web(CSS样式表、选择器)