-1

每当事件名称中有匹配项时,我想转储以下信息

1. Event ID
2. Interview ID

一旦事件名称中存在有效匹配项,是否有任何方法来回遍历。

具有类似结构的大约 1000 个事件的示例文件内容:

Event ID: 17013
Event Component: FIS
Event Type: VISA/NOA/CHAP
HINT: NORTH
Event Creator: soc-cvt
**Event Name: Up_MemRd_Unaligned_mburst_ge_0x8**
InterView ID: 22282
InterView Folder ID: 624
InterView Folder Name: SC_MainFabric_Transactions
Event Priority: 3
Sample Mode: per-seed
Event Conditional: !conditionals
CHAP Counter 0: counter_0,sum,>,10,warn`enter code here`

Event ID: 2324
Event Component: state
Event Type: VISA/NOA/CHAP
.........
4

1 回答 1

0
eid, iid = -1,-1
search_for='Up_MemRd_Unaligned_mburst_ge_0x8'
with open("input") as f:
    for line in f:
        line = line.rstrip()
        if 'Event ID' in line: eid = line.split(':')[1].strip()
        elif 'InterView ID' in line and name:
            iid = line.split(':')[1].strip()
            print "1.", eid
            print "2.", iid
        elif 'Event Name' in line:
            name = line.split(':')[1].strip(" *")
            if name != search_for: name = ""
于 2013-07-07T03:52:04.713 回答