Skip to content

Instantly share code, notes, and snippets.

@palewire
Created December 13, 2011 05:12
Show Gist options
  • Save palewire/1470713 to your computer and use it in GitHub Desktop.
Save palewire/1470713 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