擅长:python、mysql、java
<p>不需要编写自定义函数来替换字符串中的字符
python字符串对象有一个名为<code>builtin method</code>的<code>replace()</code>。你知道吗</p>
<pre><code>string.replace(s, old, new[, maxreplace])
</code></pre>
<p>它返回一个字符串的副本,其中所有出现的子字符串old都被new替换。你知道吗</p>
<p>例如:</p>
<pre><code>string = 'hello world'
new_string = string.replace('l','r', 2)
output==> herro world
</code></pre>