python中找到特定的字符并输出到另一个文件中

2025-03-09 13:55:41
推荐回答(1个)
回答1:

import re
fname = 'a.txt'
with open(fname) as f:
    s = f.read()
mwp = re.findall(r'([0-9.e+]+)\s*#\s*MWP\b', s)
width = re.findall(r'\s34\s+([0-9.e+]+)', s)