擅长:python、mysql、java
<p>看起来您将字符串模块的“replace”方法与python字符串的“replace”方法混淆了。</p>
<pre><code>string.replace("rest,"r", "t")
</code></pre>
<p>将返回“测试”</p>
<pre><code>"rest".replace("r", "t")
</code></pre>
<p>将返回“测试”</p>
<pre><code>"rest".replace("rest", "r", "t")
</code></pre>
<p>将返回您提到的错误</p>