开发者

python regexp help

Good day. Little question about reg exp.

I have a string look like

http://servercom/s开发者_开发百科mth/Age=&Filter=2&

How can i cut & with regexp from url?

After regexp url-string must be http://server.com/smth/Age=1&Filter=2&


You don't need regex for that:

changed = str.replace('&', '&');

http://docs.python.org/library/string.html#string.replace


You are translating XML escaped special characters. Use the standard lib:

>>> u = "http://servercom/smth/Age=&Filter=2&
>>> import xml.sax.saxutils
>>> xml.sax.saxutils.unescape(u)
'http://servercom/smth/Age=&Filter=2&'
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜