Python detects whether a mobile phone number is legal

Source: Internet
Author: User

1!/usr/bin/python2 #Encoding:utf-83 #This is a small script to detect whether the user entered the mobile phone number is legitimate. 4 5 defPhonecheck (s):6         #prefix, if the operator enables a new segment, simply add the new number segment to this list. 7phoneprefix=[' the','131',' the','133','134','135','136','137','138','139',' Max','151',' the','153','156','158','159',' the','183','182','185','186','188','189']8         #Check if the length of the number is legal. 9         ifLen (s) <>11:Ten                 Print "The length of Phonenum is one by one." One         Else: A                 #detects whether the numbers entered are all numbers.  -                 ifs.isdigit (): -                         #detects if the prefix is correct.  the                         ifS[:3]inchPhoneprefix: -                                 Print "The phone num is valid." -                         Else: -                                 Print "The phone num is invalid." +                 Else: -                         Print "The phone num is made up of digits." +  A  at if __name__=="__main__": -Phonenum=raw_input ("Input your phone num:") -Phonecheck (Phonenum)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.