解析.txt文件

use*_*646 1 python parsing text-files

我有一个.txt文件,如:

Symbols from __ctype_tab.o:

Name                  Value   Class        Type         Size     Line  Section

__ctype             |00000000|   D  |       OBJECT   |00000004|     |.data
__ctype_tab         |00000000|   r  |       OBJECT   |00000101|     |.rodata


Symbols from _ashldi3.o:

Name                  Value   Class        Type         Size     Line  Section

__ashldi3           |00000000|   T  |       FUNC      |00000050|     |.text
Run Code Online (Sandbox Code Playgroud)

如何解析此文件并获取类型为FUNC的函数?另外,从这个txt我怎么解析和提取.o名称?

我如何通过列式解析或其他方式获得它们.

我需要立即帮助......像往常一样等待合适的解决方案

Ale*_*lli 9

for line in open('thefile.txt'):
  fields = line.split('|')
  if len(fields) < 4: continue
  if fields[3].trim() != 'FUNC': continue
  dowhateveryouwishwith(line, fields)
Run Code Online (Sandbox Code Playgroud)

  • 您是否知道乔(Joe)是谁(http://zh.wikipedia.org/wiki/Alex_Martelli)? (2认同)