Python encoding - Nothing works
I've been looking the answers here in this web site, but nothing have worked so far. The problem is:
In the database, st开发者_如何学Crings are saved like that one: at √s = 7 TeV with
.
And the reason is that the "escape" JavaScript function was used.
I was not able to "unescape" these strings in Python yet. I tried to use "eval", "decode", "re.sub" and others, but without success. So please, which function can I use to get it right?
The string in question looks like it's encoded with HTML entities, in which case a routine like this one would be appropriate for unescaping. Here's how it looks for your string:
>>> print unescape('at √s = 7 TeV with')
at √s = 7 TeV with
urllib.unquote
should undo most if not all of the Javascript escape()
function, but specific details on what you're getting out of escape()
might help verify this
精彩评论