편집 기록

편집 기록
  • 프로필 초보자님의 편집
    날짜2021.09.24

    파이썬 텍스트파일에서 텍스트 출력하기


    텍스트파일에서 Iteration 뒤에 오는 값과 detection_eval뒤에 오는 값을 동시에 출력하고 싶은데요 어떤식으로 표현하면될까요?현재는 detection_eval 뒤에 오는 값만 출력할수있는 상태입니다.

    print("Iteration,detection_eval")
    for line in lines:
            if "detection_eval = " in line:
                    item = line.split("detection_eval = ")
                    Detection_eval = item[1].rstrip('\n')
                    print(Detection_eval)
    

    아래는 작성한 전체코드입니다.

    <pre>import re
    file = open(r"C:\Users\영업지원\Desktop\03_parsing_csv_plot\vgg16_recog_107_20210112.log",'rt',encoding='UTF8')
    lines = file.readlines()
    pt = re.compile(r'Iteration ([\d]+), loss = ([\w.]+)')
    fs = pt.findall(str(lines))
    print("Iteration,loss")
    for f in fs:
            print(int(f[0]), float(f[1]))
    file.close()
    print("Iteration,detection_eval")
    for line in lines:
            if "detection_eval = " in line:
                    item = line.split("detection_eval = ")
                    Detection_eval = item[1].rstrip('\n')
                    print(Detection_eval)
            if "Iteration " in line:
                    item = line.split("Iteration ")
                    Iteration = item[1].rstrip('\n')
                    print(Iteration)
    file.close()
    
  • 프로필 알 수 없는 사용자님의 편집
    날짜2021.09.24

    파이썬 텍스트파일에서 텍스트 출력하기


    텍스트파일에서 Iteration 뒤에 오는 값과 detection_eval뒤에 오는 값을 동시에 출력하고 싶은데요 어떤식으로 표현하면될까요?현재는 detection_eval 뒤에 오는 값만 출력할수있는 상태입니다.

    print("Iteration,detection_eval") for line in lines: if "detection_eval = " in line: item = line.split("detection_eval = ") Detection_eval = item[1].rstrip('\n') print(Detection_eval) 아래는 작성한 전체코드입니다. import re file = open(r"C:\Users\영업지원\Desktop\03_parsing_csv_plot\vgg16_recog_107_20210112.log",'rt',encoding='UTF8') lines = file.readlines() pt = re.compile(r'Iteration ([\d]+), loss = ([\w.]+)') fs = pt.findall(str(lines)) print("Iteration,loss") for f in fs: print(int(f[0]), float(f[1])) file.close() print("Iteration,detection_eval") for line in lines: if "detection_eval = " in line: item = line.split("detection_eval = ") Detection_eval = item[1].rstrip('\n') print(Detection_eval) if "Iteration " in line: item = line.split("Iteration ") Iteration = item[1].rstrip('\n') print(Iteration) file.close()