Skip to content

Instantly share code, notes, and snippets.

@luabida
Created May 18, 2023 18:08
Show Gist options
  • Save luabida/40ba690f7ae8c694961a6a2f16e7fd54 to your computer and use it in GitHub Desktop.
Save luabida/40ba690f7ae8c694961a6a2f16e7fd54 to your computer and use it in GitHub Desktop.
Normalize string
import unicodedata
def normalize_str(string: str) -> str:
non_ascii = (
unicodedata.normalize("NFKD", string).encode("ascii", "ignore").decode()
)
string = non_ascii.lower().replace(" ", "_")
return string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment