擅长:python、mysql、java
<p>你可以用正则表达式来解决它和其他类似的问题。你知道吗</p>
<p>首先你需要找到时间戳</p>
<pre><code> regexTimeStamp = re.complie('\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}.\d{3}')
</code></pre>
<p>那你可以用</p>
<pre><code>match = regexTimeStamp.match(Str)
</code></pre>
<p>这里我使用Str作为文件中的一行。
然后使用<code>TimeStamp = match.group()</code>来获取时间戳</p>
<p>现在同样使用正则表达式来查找</p>
<pre><code>regexStat = re.compile('STATISTICS:')
match1 = regexStat.match(str)
match1.start()
</code></pre>
<p>将为您提供统计数据的起始索引:
你可以在那之前加上时间戳。你知道吗</p>
<p><a href="https://docs.python.org/2/howto/regex.html" rel="nofollow">here is a guide on regex</a></p>
<p><a href="https://regex101.com/" rel="nofollow">and here is for hit and try</a></p>