Run
import phonenumbers import pycountry # Take phone number in a string phonenumber_string = "+442083661177" # Parse the string to a PhoneNumber object x = phonenumbers.parse(phonenumber_string) print('Country code :', x.country_code) # Get region code region_code = phonenumbers.region_code_for_country_code(x.country_code) print('Region code :', region_code) # Get country name country = pycountry.countries.get(alpha_2=region_code) name = country.name print('Country name :', name)
Output