Skip to content

Instantly share code, notes, and snippets.

@TurRil
Forked from palewire/stripdict.py
Created December 12, 2022 08:00
Show Gist options
  • Save TurRil/381681c3f2840d197da6657e0fbe1206 to your computer and use it in GitHub Desktop.
Save TurRil/381681c3f2840d197da6657e0fbe1206 to your computer and use it in GitHub Desktop.
Strip leading and trailing whitespaces in dictionary keys and values
def strip_dict(d):
"""
Strip all leading and trailing whitespace in dictionary keys and values.
"""
return dict((k.strip(), v.strip()) for k, v in d.items())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment