« Python modules

phonenumbers


validate phone numbers in python
If you need to validate phone numbers in python the phonenumbers module is a great library Installation Instructions pip install phonenumbers Example import phonenumbers x = phonenumbers.parse("+442083661177", None) print(x) type(x) y = phonenumbers.parse("020 8366 1177", "GB") print(y) print(x == y) # as dialed from GB, not a GB number z = phonenumbers.parse("00 1 650 253 2222", "GB") print(z) z = phonenumbers.parse("+120012301", None) phonenumbers.is_valid_number(z) # output Country Code: 44 National Number: 2083661177 Country Code: 44 National Number: 2083661177 True Country Code: 1 National Number: 6502532222 False As you type phone number validation Read More →