一、正则表达式

#正则引入                                                   

用户输入手机号后怎么样辨别是否合法呢?看我python的!常规写法一句一句逐个条件来?low不low

04 正则表达式 和 re模块
while True:
    phone_number = input('please input your phone number : ')
    if len(phone_number) == 11 \
            and phone_number.isdigit()\
            and (phone_number.startswith('13') \
            or phone_number.startswith('14') \
            or phone_number.startswith('15') \
            or phone_number.startswith('18')):
        print('是合法的手机号码')
    else:
        print('不是合法的手机号码')
我一句一句来!

相关文章:

  • 2021-11-13
  • 2021-06-30
  • 2021-07-22
  • 2021-11-04
  • 2021-11-22
猜你喜欢
  • 2021-08-18
  • 2021-09-27
  • 2022-12-23
相关资源
相似解决方案