python验证手机号码小程序代码
写的代码太烂了,请大家帮帮忙改进改进,谢谢。左边题目,右边代码。
cnmobile =
cnunion =
cntelecom =
def num():
num = input('enter your number:')
while len(num) != 11:
if num.startswith(str(cnmobile[:])):
print('operator : China mobile')
print('we are sending verification code via text to your phone:',num)
elif num.startswith(str(cnunion[:])):
print('operator : China union')
print('we are sending verification code via text to your phone:',num)
elif num.startswith(str(cntelecom[:])):
print('operator : China telecom')
print('we are sending verification code via text to your phone:',num)
elif num not in (cnmobile,cnunion,cntelecom):
print('no such a operator')
break
print('invalid length,your number should be in 11 digits')
num()
号段不全,73和191是电信新号段,里面没有加进去 正则不是更简洁 这是判断运营商的?
在具体下可以添加归属地。 为啥子不用正则呢??? 用正则不是更好吗{:301_1001:} 用正则吧 为何不直接调用。。。其他网站提供的api ? https://tool.bitefu.net/shouji/?mobile=手机号
api
在给你个库 https://github.com/xluohome/phonedata 以后就没啥用啦,到处是携号转网的人