Skip to content

Instantly share code, notes, and snippets.

@tlevine
Last active January 1, 2016 20:59
Show Gist options
  • Save tlevine/8200901 to your computer and use it in GitHub Desktop.
Save tlevine/8200901 to your computer and use it in GitHub Desktop.
Decoding hex strings in python
In [76]: content_disposition = 'attachment;filename="Liste des pr\xe9noms 2004-2012.ods"'
In [77]: print(content_disposition)
attachment;filename="Liste des proms 2004-2012.ods"
In [78]: print eval("u'''%s'''" % content_disposition)
attachment;filename="Liste des prénoms 2004-2012.ods"
In [79]: u'How do I do this without eval?'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment