擅长:python、mysql、java
<p>代码的问题是re模块中有两个子函数。一个是通用的,还有一个与正则表达式对象相关。您的代码不遵循以下任一项:</p>
<p>这两种方法是:</p>
<p><code>re.sub(pattern, repl, string[, count])</code><a href="http://docs.python.org/library/re.html#re.sub" rel="nofollow noreferrer">(docs here)</a></p>
<p>这样使用:</p>
<pre><code>>>> y = re.sub(r, 'blue', x)
>>> y
'The sky is blue'
</code></pre>
<p>当您在手动编译时,您可以使用:</p>
<p><code>RegexObject.sub(repl, string[, count=0])</code><a href="http://docs.python.org/library/re.html#re.RegexObject.sub" rel="nofollow noreferrer">(docs here)</a></p>
<p>这样使用:</p>
^{pr2}$