Created
December 13, 2009 23:09
-
-
Save justinabrahms/255657 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Escaped string issue. | |
encoded_str = "Caf\\xc3\\xa9" | |
encoded_str.replace('\\\\', '\') | |
# returns: "Caf\\xc3\\xa9" | |
encoded_str.replace('\\', '') | |
# returns: "Cafxc3xa9" | |
import re | |
re.sub('\\\\', '\\', encoded_str) | |
# returns: "Caf\\xc3\\xa9" | |
# This one works | |
encoded_str.decode('string_escape') | |
# returns: "Caf\xc3\xa9" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment