How to validate email in Python with 5 lines of code

Опубликовано: 09 Октябрь 2024
на канале: Rester Test
460
4

How to validate email in Python with 5 lines of code

https://www.geeksforgeeks.org/check-i...

https://pypi.org/project/email-valida...

from email_validator import validate_email, EmailNotValidError

email = "[email protected]"

try:
Validate & take the normalized form of the email
address for all logic beyond this point (especially
before going to a database query where equality
does not take into account normalization).
email = validate_email(email).email
except EmailNotValidError as e:
email is not valid, exception message is human-readable
print(str(e))