Extract Phone Number Details using Python
There are many tasks when we have to extract the detail's of a person's phone number. There are many apps created for this. But What If we create our own with Python. If you want to learn how to extract details of phone number using Python, then this article is for you. In this article you will learn to Extract Phone Number details using Python. So, let's start without wasting any more time.
Extract Phone Number Details using Python
For extracting details of any number, we have to install an amazing Python module known as phonenumbers.
To install the required module on your system, open the command prompt (cmd) or terminal and execute the following pip command.
pip install phonenumbers
Also read - How to make an Audiobook with Python
Now, after you have installed this module let's code to find some details of the phone number. There are lot of things you can find using this module. Here are some of the details that you can extract using this Python module.
timezone - Get list of time zones that the number belongs to.
carrier - For mobile numbers in some countries, you can also find out the information about which carrier originally owned the number.
geocoder - Get information about the location that corresponds to the phone number.
This is the code to extract the above details about the phone number using Python.
import phonenumbers as pn
from phonenumbers import carrier
from phonenumbers import geocoder
from phonenumbers import timezone
number = "+9189XXXXXXXX"
number = pn.parse(number)
print(timezone.time_zones_for_number(number))
print(carrier.name_for_number(number, "en"))
print(geocoder.description_for_number(number, "en"))
This is how you can find some of the basic details about a phone number using Python. To get complex details about the phone numbers, refer to the documentation of the phonenumbers module available on GitHub.
I hope you liked this article on "Extract Phone Number details using Python". In case of any doubt, feel free to ask in the comments below.
Also, share this article so that more people can take advantage of the content.
Enjoy Coding!!!
Post a Comment
For any doubts feel free to ask in comments below.
Stay Connected to Us for more such Courses and Projects.