Sanitize, validate and format phone numbers into E.164 valid phone numbers.
Project description
py-phone-number-fmt
Sanitize, validate and format phone numbers into E.164 valid phone numbers.
Google's libphonenumber on steroids. Tries all sorts of crazy combinations in an attempt to create a valid phone number. Useful for those of us who have to deal with poorly sanitized data.
Installation
$ pip install py-phone-number-fmt
Usage
from phonenumberfmt import format_phone_number
# implied phone region is the country of which to
# use the dialing prefix in case the number appears
# to be local
result = format_phone_number('778\173 0.92', implied_phone_region='RO')
assert result == '+40778173092'
The resulting phone number will be formatted according to the E.164 standard. Want to change the output format? Pass the third, optional parameter fmt
with a valid member of phonenumbers.NumberFormat
:
from phonenumbers import NumberFormat
result = format_phone_number(
'778\173 0.92',
implied_phone_region='RO',
fmt=NumberFormat.INTERNATIONAL, # default is NumberFormat.E164
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for py-phone-number-fmt-1.0b2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5db591973dbd62a90ff50a19f0010e3ef18e17387a8adbbd46251e94290c7cb |
|
MD5 | 3e1559af5d541802e333cd64db85cc3d |
|
BLAKE2b-256 | 23321fc565096bc97d68e8af30e93d44965bf93388ea2cf6eb4a0ef60194bb83 |