擅长:python、mysql、java
<p>只是提取时间的另一种方法-在“fuzzy”模式下使用<a href="https://labix.org/python-dateutil" rel="nofollow noreferrer">^{<cd1>}</a>:</p>
<pre><code>In [1]: from dateutil.parser import parse
In [2]: s = "'Mys dreyn M (00:07:04): Yes', ' of course.\r\n'"
In [3]: dt = parse(s, fuzzy=True) # dt is a 'datetime' object
In [4]: dt.hour
Out[4]: 0
In [5]: dt.minute
Out[5]: 7
In [6]: dt.second
Out[6]: 4
</code></pre>
<hr/>
<p>至于正则表达式,我也会通过检查数字对来改进它:</p>
^{pr2}$