python-随机生成有效11位手机号码

在工作中,总会遇到数据整理,尤其是手机号码的有效性。以下是用python语言随机生成10个随机手机号码!
# coding:utf-8
import random


def createPhone():
    for k in range(10):
        prelist=["130", "131", "132", "133", "134", "135", "136", "137", "138", "139",
                 "147", "150", "151", "152", "153", "155", "156", "157", "158", "159",
                 "186", "187", "188", "189"]
        print random.choice(prelist)+"".join(random.choice("0123456789") for i in range(8))

createPhone()

猜你喜欢

转载自blog.csdn.net/hhy_123963/article/details/85337343