首页 > 编程语言 > 详细

python自动生成电话号

时间:2020-05-10 23:06:33      阅读:63      评论:0      收藏:0      [点我收藏+]
# Author:BeeLe

# -*- coding: utf-8 -*-
import random


def create_phone():
# 第二位数字
second = [3, 4, 5, 7, 8][random.randint(0, 4)]
# 第三位数字
third = {3: random.randint(0, 9),
4: [5, 7, 9][random.randint(0, 2)],
5: [i for i in range(10) if i != 4][random.randint(0, 8)],
7: [i for i in range(10) if i not in [4, 9]][random.randint(0, 7)],
8: random.randint(0, 9), }[second]
# 最后八位数字
suffix = random.randint(9999999, 100000000)
# 拼接手机号
return "1{}{}{}".format(second, third, suffix)
# p = create_phone()
# 生成手机号
# print(p)

python自动生成电话号

原文:https://www.cnblogs.com/lee88888/p/12865600.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!