开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜