请教日常文本txt文件处理,提取(我编辑了一下,txt格式有变)

  • s
    summerblue52
    回复50#zhouxl2000

    我试试
  • s
    summerblue52
    回复50#zhouxl2000

    确实简单易用,感谢
  • P
    Pyrrhus
    用python吧,没几行代码


    1. #-*- coding: UTF-8 -*-
    2. import uniout # 打印unicode
    3. import re

    4. f='test202002.txt'
    5. for line in open(f):
    6. matchObj = re.search (r'^\d+ {8,}', line)
    7. if matchObj:
    8. print line
    复制代码
  • s
    summerblue52
    我也写了个正则
    1. (----+\s((?:.*?\r?\n?)*)\(结果个数)+
    复制代码
  • s
    summerblue52
    改了下上上楼python3的写法
    1. import re

    2. f='AAAA.txt'
    3. for line in open(f):
    4. matchObj = re.search (r'^\d+ {8,}', line)
    5. if matchObj:
    6. print(line)
    复制代码
  • 7
    77880099
  • 大部头书
    anaconda