DEV Community

L1GEND
L1GEND

Posted on

Get Phone Number Details Using Python

Get Any Phone Number Details Using phonenumbers Python Library

Image description

*1- Import Library : *

import phonenumbers 
Enter fullscreen mode Exit fullscreen mode

*2- import modules *

from phonenumbers import carrier , geocoder , timezone 
Enter fullscreen mode Exit fullscreen mode

*3- Prompt User *

Number = input('Please Enter Your Number With Country Code : ')
Enter fullscreen mode Exit fullscreen mode

*4- Parse User Input *

Number = phonenumbers.parse(Number)
Enter fullscreen mode Exit fullscreen mode

*5- Print Timezone *

print(timezone.time_zones_for_number(Number))
Enter fullscreen mode Exit fullscreen mode

*6-Print Phone Number Carrier : *

print(carrier.name_for_number(Number,"en"))
Enter fullscreen mode Exit fullscreen mode

*6-Print Phone Number Country : *

print(geocoder.description_for_number(Number , "en"))
Enter fullscreen mode Exit fullscreen mode

*7-Check Phone Number Validity : *

print('Valid Mobile Number : ',phonenumbers.is_valid_number(Number))
Enter fullscreen mode Exit fullscreen mode

Top comments (0)