Skip to content

Instantly share code, notes, and snippets.

@justxor
Created June 2, 2022 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justxor/a7aa191f0fac058b5702651639af6a10 to your computer and use it in GitHub Desktop.
Save justxor/a7aa191f0fac058b5702651639af6a10 to your computer and use it in GitHub Desktop.
>>> import phonenumbers
>>> x = phonenumbers.parse("+442083661177", None)
>>> print(x)
Country Code: 44 National Number: 2083661177 Leading Zero: False
>>> type(x)
<class 'phonenumbers.phonenumber.PhoneNumber'>
>>> y = phonenumbers.parse("020 8366 1177", "GB")
>>> print(y)
Country Code: 44 National Number: 2083661177 Leading Zero: False
>>> x == y
True
>>> z = phonenumbers.parse("00 1 650 253 2222", "GB") # as dialled from GB, not a GB number
>>> print(z)
Country Code: 1 National Number: 6502532222 Leading Zero(s): False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment