idna

Convert between Unicode domain names and ASCII-compatible encoding.

pipmacoslinuxwindows
Try with needOr install directly
Source

About

Internationalized Domain Names in Applications (IDNA)

Examples

convert international domain name to ASCII format$ python3 -c "import idna; print(idna.encode('münchen.de'))"
decode ASCII domain name back to unicode$ python3 -c "import idna; print(idna.decode(b'xn--mnchen-3ya.de'))"
handle emoji and non-latin characters in domain names$ python3 -c "import idna; print(idna.encode('日本.jp'))"
validate internationalized domain name is correct$ python3 -c "import idna; idna.encode('café.fr'); print('Valid')"