擅长:python、mysql、java
<p>我想这是你想要的:</p>
<pre><code>import re
my_list = ["The Term' means 125 years commencing on and including 01 October 2015.",
"125 years commencing on 25th December 1996",
"the term of 999 years from the 1st January 2011",
]
for item in my_list:
new_item = re.sub("\d+\syears", "", item)
print(new_item)
</code></pre>
<p>结果:</p>
^{pr2}$
<p>注意,你最后会有一些额外的空白(也许你想要)?但你也可以把这个加到“清理”中:</p>
<pre><code>new_item = re.sub("\s+", " ", new_item)
</code></pre>
<p><s>因为我喜欢regex:new_item=re.sub公司(“^\s+|\s+$”,“”,新项)</s></p>
<pre><code>new_item = new_item.strip()
</code></pre>