python随机生成有效手机号码
Posted 卓_然
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python随机生成有效手机号码相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @author simpelzhuo
import random
class PhoneNOGenerator():
# 随机生成手机号码
def phoneNORandomGenerator(self):
prelist=["130","131","132","133","134","135","136","137","138","139","147","150","151","152","153","155","156","157","158","159","186","187","188"]
return random.choice(prelist)+"".join(random.choice("0123456789") for i in range(8))
if __name__ == ‘__main__‘:
pg = PhoneNOGenerator()
print(pg.phoneNORandomGenerator())
以上是关于python随机生成有效手机号码的主要内容,如果未能解决你的问题,请参考以下文章
如何生成1亿个手机号码?Python生成随机数的22种方法,random函数太强了