<p>我有一个下面的文件,如何提取行是有5.6版本号。我需要找到正则表达式的模式</p>
<pre><code>A KB 1024 MYsql root
B GB 1 ELK-6
C KB 1024 Mysql5.6
E KB 1024 ELK
F GB 1 Mysql5.6
</code></pre>
<p>预计出局</p>
<pre><code>C KB 1024 Mysql5.6
F GB 1 Mysql5.6
</code></pre>
<p>我的熊猫代码</p>
<pre><code>import re
infile = r'C:\user\Desktop\m.txt'
df_list = []
with open(infile) as f:
for line in f:
# remove whitespace at the start and the newline at the end
line = line.strip()
# split each column on whitespace
columns = re.split('\s+', line, maxsplit=4)
df_list.append(columns)
df = pd.DataFrame(df_list)
df[df[3].str.contains("5.6")]
</code></pre>
<p>我需要用Python处理regex,而不是用dataframe。我没有给熊猫贴标签</p>