1 2 3 4 5 6 7 8 9 10 11 12 13
| import re def judge_Monile_phone(phone): if len(phone)==11: rp=re.compile('^0\d{2,3}\d{7,8}$|^1[358]\d{9}$|^147\d{8}') phoneMatch = rp.match(phone) if phoneMatch: print('手机号正确!') else: print("手机号码错误!") else: print("号码长度错误!") if __name__ == "__main__": judge_Monile_phone('13412341234')
|