擅长:python、mysql、java
<p>你是说这个?</p>
<pre><code>>>> import re
>>> m = re.sub(r'10', r'20', "hello number 10, Agosto 19")
>>> m
'hello number 20, Agosto 19'
</code></pre>
<p>或者</p>
<p>使用lookbehind</p>
<pre><code>>>> number = "20"
>>> number
'20'
>>> m = re.sub(r'(?<=number )\d+', number, "hello number 10, Agosto 19")
>>> m
'hello number 20, Agosto 19'
</code></pre>