6
A
回答
15
您应该使用HTMLParser
模块decode html:
>>> import HTMLParser
>>> h= HTMLParser.HTMLParser()
>>> h.unescape('alpha < β')
u'alpha < \u03b2'
为了逃避HTML,cgi module is fine:
>>> cgi.escape(u'<a>bá</a>').encode('ascii', 'xmlcharrefreplace')
'<a>bá</a>
+0
伟大的链接。 – bernie 2009-12-30 15:33:57
相关问题
- 1. 如何将linq组IQueryable <IEnumerable <T>>更改为IQueryable <T>?
- 2. 如何将“<url>”改为“</url>”为List?
- 3. 为什么编辑时FCKeditor将`<`更改为`<`并且`>`更改为`>`?
- 4. 如何更改ui-> widget-> windowOpacity?
- 5. 如何:* .csv - > line - > someArray - >修改
- 6. 如何将JavaScript中的>>>运算符转换为VB.NET?
- 7. 使用jquery将<span> html更改为<tr> ...</tr>
- 8. >>转换为
- 9. 将<h:outputText>更改为<h:inputText> ajax在PrimeFaces
- 10. Eclipse:将默认HTML评论从<!-- -->更改为<!--/* */-->?
- 11. 将<body>更改为<body id“something”runat =“server”>
- 12. <select>将<option>更改为逗号
- 13. 如何将IObservable <IObservable <T>>转换为IObservable <IEnumerable <T>>?
- 14. 如何将List <IEnumerable <ProductViewModel >>转换为<IEnumerable <ProductViewModel >>?
- 15. 如何将UnsafeMutablePointer <UnsafeMutablePointer <Int8>?>转换为UnsafeMutablePointer <UnsafeMutablePointer <Int8>>!
- 16. 如何将shared_ptr <Foo<Derived>>转换为shared_ptr <Foo<Base>>?
- 17. 为什么<$>和<*>的输入顺序是>> =?
- 18. 为什么10 >> 2 + 5 >> 2评估为零?
- 19. 为什么Python 2.7中的`()>''> []> {}> 0> None`?
- 20. iOS >>块>>更改块外部变量的值
- 21. 将<input>更改为@ Html.RadioButtonFor?
- 22. 将列表<int>更改为int []
- 23. 将按钮更改为<a>
- 24. 将颜色更改为<ice:commandLink>
- 25. 如何将我的代码更改为横向?在iPad上</p> <pre><code>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{} </code></pre> <p>:
- 26. 将lambda类型从int => IEnumerable <string>>转换为int =>任务<IEnumerable <string> >>?
- 27. 为什么(-1 >>> 32)= -1?
- 28. 将`=>单元转换为`()=>单元`
- 29. Sed将“>”替换为“/>”bash
- 30. 为什么在Python 1.0 == 1 >>> True; -2.0 == -2 >>>真等等?
我不会做Python,但那些被称为“HTML实体”。如果您在Google中使用该新关键字,您可能会发现足够的信息:http://www.google.com/search?q=python+html+entities – BalusC 2009-12-30 01:09:42
这不可能是足够的,BalusC。 OP在他的档案中明确指出,英文解释难以理解,他希望**代码**。 *考虑到问题的形式是代码* – pavium 2009-12-30 01:14:44
耶,BalusC,发送给他HTML0Parser的+1和c0dez – SilentGhost 2009-12-30 01:16:59