第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 python groupby 從給定的文本文件中拆分測試名稱和日志詳細信息

如何使用 python groupby 從給定的文本文件中拆分測試名稱和日志詳細信息

繁星點點滴滴 2021-08-11 17:11:13
從以下輸入文件中,我想拆分testname和關聯(lián)logdetails輸入文件:2/1/1/2/tasdf.c:LOG:        backslash-newline should be deleted before tokenizing    No diagnostics lineRESULT: 2/1/1/2/tasdf.c                                          FAILED----------------------------------------2/1/1/2/tlasdf.c:LOG:+++ stderr ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++tlasdf.c:15:5: error: use of undeclared identifier '_t'    t x[] = L\    ^ls: cannot access '*.o': No such file or directory+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++    | T | Translation Phases | 2 | \\ | L | 2 |    Compilation failedRESULT: 2/1/1/2/tlasdf.c                                          FAILED----------------------------------------2/2/4/1/texasdfgen(0):LOG:    511 external identifiers in one source file    Compilation failed ungracefullyRESULT: 2/2/4/1/textasdf.gen                                    FAILED用于拆分的代碼:import reimport sys#inputfileTEST = sys.argv[1]#Open input file and match testnamedef testname(FILE):    testlist=[]    for line in open(FILE, 'r+'):        match1 = re.search(r'.*\.c\:$|.*\.gen\(\d+\)\:$', line)        if match1:            testname = match1.group(0)            testlist.append(testname)    return(testlist)#Open input file and match log detailsdef logdetail(FILE):array = []with open(TEST) as f:    for line in f:        if line.startswith('LOG:'):            for line in f:                if line.startswith('RESULT:'):                    break             # else process lines from section                array.append(line)print(array)    testname = testname(TEST)for test in testname:    print (test)        loddetails = logdetail1(TEST)for log in loddetails:    print(log)testname正確打印并且日志詳細信息存在于數(shù)組中,但如何testname與logdetails.
查看完整描述

2 回答

?
HUWWW

TA貢獻1874條經(jīng)驗 獲得超12個贊

首先做以下修改logdetail():


def logdetail(FILE):

    collect = False

    array = []

    current = []

    with open(FILE, 'r+') as f:

        for line in f:

            if line.startswith('LOG:'):

                collect = True

            else:

                if line.startswith('RESULT: '):

                    collect = False

                    array.append(current)

                    current=[]

                if collect:

                    current.append(line.strip())


    return(array)

然后用它來打印(假設總是len(testname) = len(logdetails))


testname = testname(TEST)

loddetails = logdetail1(TEST)

for test in testname:

    print (test + '\t' +  " ".join(logdetail1[testname.index(test)])) 


查看完整回答
反對 回復 2021-08-11
  • 2 回答
  • 0 關注
  • 166 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號