A Python library that maps phone numbers (E.164 format) to their corresponding country codes (ISO 3166-1 alpha-2). Version 0.4.1 provides a simple `CountryCodeResolver` class and a convenience function `phone_country`. Lightweight with no external dependencies.
pip install phone-iso3166Verified import paths — ran on the pinned version, not inferred.
Import the `country_code` function and pass an E.164 formatted phone number (string with leading +). Returns ISO 3166-1 alpha-2 country code or None if not found.
Always include the '+' prefix, e.g., '+14155552671'.
Use in conjunction with a phone number validation library like `phonenumbers` if you need validation.
Use `country_code` function instead of instantiating `CountryCodeResolver`.
No dependency data recorded yet.