I want to use python phonenumbers to get the number of digits that mobile phones have to have for each country.
I'm importing the phonenumbers/libphonenumber library.
I tried fetching the metadata with no success. Then I tried fetching an example number to then deduce it from there. It looks like I'm not being able to give with the adequate attributes or classes to fetch these. Do you know which are the attributes or classes I need to look for in order to get to this information?
country = phonenumbers.region_code_for_country_code(country_code)
metadata = phonenumbers.metadata_for_region(country)
or
region_code = phonenumbers.region_code_for_country_code(country_code)
example_number = phonenumbers.get_example_number_for_type(region_code, phonenumbers.PhoneNumberType.MOBILE)
I'm open to using other libraries too.
You can try this code that retrieves the required number of digits of a mobile phone number in a specific country using your database:
The database phone_number_format.db has a table named phone_number_format with columns country_code and num_digits. The get_mobile_number_digits function takes a country_code as input and returns the required number of digits for that country code. If the country code is not found in the database, the function returns None.