加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python开发_html_html处理

发布时间:2020-12-17 00:19:58 所属栏目:Python 来源:网络整理
导读:div class="cnblogs_code" 模块提供了只提供了一个方法: html.escape(s,quote = True) 该方法主要是把html文件中的特殊字符(, ,",'等)转换为HTML-safe字符 下面是我做的一个demo: : Python 3.3.2 (v3.3.2:d047928ae3f6,May 16 2013,00:03:43) [MSC v.1600

<div class="cnblogs_code">

模块提供了只提供了一个方法:
   html.escape(s,quote = True)
       该方法主要是把html文件中的特殊字符(&,<,>,",'等)转换为HTML-safe字符

下面是我做的一个demo:

Python 3.3.2 (v3.3.2:d047928ae3f6,May 16 2013,00:03:43) [MSC v.1600 32, >>> ================================ RESTART ================================ >>> > Python Html module content=> content=> content=> content=> > >http://www.blogs.com/hongten

<span style="color: #008000;">#<span style="color: #008000;">#################################################
<span style="color: #000000;">转换html文件:
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&amp;quot;&amp;<span style="color: #000000;">gt;
&lt;html&<span style="color: #000000;">gt;
&lt;head&<span style="color: #000000;">gt;
&lt;title&gt; Python Html module &lt;/title&<span style="color: #000000;">gt;
&lt;meta name=&quot;Generator&quot; content=&quot;EditPlus&quot;&<span style="color: #000000;">gt;
&lt;meta name=&quot;Author&quot; content=&quot;Hongten&quot;&<span style="color: #000000;">gt;
&lt;meta name=&quot;Keywords&quot; content=&quot;hongten,python&quot;&<span style="color: #000000;">gt;
&lt;meta name=&quot;Description&quot; content=&quot;this blogs <span style="color: #0000ff;">is about python&quot;&<span style="color: #000000;">gt;
&lt;/head&<span style="color: #000000;">gt;

&lt;body&<span style="color: #000000;">gt;
&lt;table border = &quot;1&quot;&<span style="color: #000000;">gt;
&lt;tr&<span style="color: #000000;">gt;
&lt;td&<span style="color: #000000;">gt;
Author
&lt;/td&<span style="color: #000000;">gt;
&lt;td&<span style="color: #000000;">gt;
Hongten
&lt;/td&<span style="color: #000000;">gt;
&lt;td&<span style="color: #000000;">gt;
Mail
&lt;/td&<span style="color: #000000;">gt;
&lt;td&<span style="color: #000000;">gt;
hongtenzone@foxmail.com
&lt;/td&<span style="color: #000000;">gt;
&lt;/tr&<span style="color: #000000;">gt;
&lt;tr&<span style="color: #000000;">gt;
&lt;td&<span style="color: #000000;">gt;
Blos
&lt;/td&<span style="color: #000000;">gt;
&lt;td&<span style="color: #000000;">gt;
&lt;a href=&quot;http://www.blogs.com/hongten&amp;quot;&amp;gt;http://www.blogs.com/hongten&amp;lt;/a&amp;<span style="color: #000000;">gt;
&lt;/td&<span style="color: #000000;">gt;
&lt;td&<span style="color: #000000;">gt;
QQ
&lt;/td&<span style="color: #000000;">gt;
&lt;td&<span style="color: #000000;">gt;
648719819
&lt;/td&<span style="color: #000000;">gt;
&lt;/tr&<span style="color: #000000;">gt;
&lt;/table&<span style="color: #000000;">gt;
&lt;/body&<span style="color: #000000;">gt;
&lt;/html&<span style="color: #000000;">gt;

>>>

经过源文件内容和转换后的内容相比较,我想你知道方法的作用了吧

HTML_STR = HTML_STR = Python Html module ( ( * 50 old_str = ( == main()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!