1. 程式人生 > >python隨機生成有效手機號碼

python隨機生成有效手機號碼

dom 號碼 elf pri gen sim () usr print

#!/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隨機生成有效手機號碼