我需要指出在這個問題的正確方向查找多個字符串紀錄我的工作:最佳方法在Python
比方說,我是從一個C程序讀取輸出如下:
while True:
ln = p.stdout.readline()
if '' == ln:
break
#do stuff here with ln
而且我的輸出看起來像這行線:
TrnIq: Thread on CPU 37
TrnIq: Thread on CPU 37 but will be moved to CPU 44
IP-Thread on CPU 33
FANOUT Thread on CPU 37
Filter-Thread on CPU 38 but will be moved to CPU 51
TRN TMR Test 2 Supervisor Thread on CPU 34
HomographyWarp Traking Thread[0] on CPU 26
我想捕捉「TrnIq:線程」和「37」作爲兩個獨立的變量:一個字符串和一個數字從輸出「TrnIq :在CPU上線程37" 。
對於其他行,例如捕獲「HomographyWarp Traking Thread [0] on」和#「26」,來自「在CPU 26上的HomographyWarp Traking Thread [0]」,它相當不錯。
唯一真正的挑戰是這樣的行:「在CPU 38上的過濾器線程,但將被移動到CPU 51」,我需要「Filer-Thread」和#「51」不是第一個#「 38" 。
Python有很多不同的方法來做到這一點我甚至不知道從哪裏開始!
在此先感謝!
「Thanks」for unaccaptance ... – 2012-07-24 20:15:10