WSGI:Python:我的函数可能没有执行;单程“;尝试替换html字符时

WSGI:Python:我的函数可能没有执行;单程“;尝试替换html字符时,python,python-2.7,mod-wsgi,wsgi,Python,Python 2.7,Mod Wsgi,Wsgi,问题是。。esc功能 当我只在该函数中保留1项时 它实际上工作正常 但是当我有所有这些替换行时.. 我认为这是一个多重过程,因此我最终得到了 &lt;img src=&quot;&quot;&gt; 在网络上而不是 <img src=""> #编码:utf-8 def esc(a): a=a.替换(“,”) a=a.replace(“”,“”) a=a.替换(“'”、“';”) a=a.替换(“&”和“&;”) 归还 def应用程

问题是。。esc功能
当我只在该函数中保留1项时
它实际上工作正常

但是当我有所有这些替换行时..
我认为这是一个多重过程,因此我最终得到了

&lt;img src=&quot;&quot;&gt;
在网络上而不是

<img src="">

#编码:utf-8
def esc(a):
a=a.替换(“,”)
a=a.replace(“”,“”)
a=a.替换(“'”、“';”)
a=a.替换(“&”和“&;”)
归还
def应用程序(环境、启动和响应):
b=“”
b=esc(b)
开始响应('200OK',[('Content-Type','text/html'))
产量b
试试这个:

import html
def esc(a):
  return html.escape(a)

将第五行移到顶部
import html
def esc(a):
  return html.escape(a)