Python

Little Mail Validator in Python

wrote a little Mail Adresse Validator in Python. use it, modify it, like it … best practice for python is to use a virtual env like Poetry (or virtualenv) and add the “email-validator” module like this: poetry add email-validator Code few lines of code … #!/usr/bin/env python3 from email_validator import validate_email, EmailNotValidError ok=[] nok=[] emails = [ "my+address@mydomain.tld", "hans@dampf.ch", "gott@welt.net", "adsf@asdf.com", "asf.asdf", "franz!mueller@abc.com", "asdf@asdf.adf" ] print ("\nMy Little Mail Validator\n") for email in emails: try: # Validate.

Python

Python Snippets RealPython Best Practices: https://realpython.com/tutorials/best-practices/ Convert CSV to JSON cat LARGEFILE.csv |python3 -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > LARGEFILE.json Zfill Padding Zero >>> for i in range(1,10): ... str(i).zfill(4) '0001' '0002' '0003' ... Different Padding #!/usr/bin/env python3 for i in range(1,99): print( str(i).zfill(4) +" "+ str(i).rjust(4, '-') +" "+ str(i).ljust(4, '-') +" "+ str(i).center(4, '-') ) 0001 ---1 1--- -1-- 0002 ---2 2--- -2-- 0003 ---3 3--- -3-- .