Python 텍스트 파싱과 매칭되는 단어 찾기
logfile = open("logfile.txt", "r").readlines()
KEYWORDS = ['test', 'text']
counterline = []
counter = 0
for line in logfile:
for word in line.split():
counter+=1
if word in KEYWORDS:
counterline.append(counter)
print word
print KEYWORDS
print counterline
'Technology > Programming' 카테고리의 다른 글
| Python / Python 기본 파일 입출력, Parsing (0) | 2012.09.05 |
|---|---|
| Python / 숫자, 소수점 정규표현식 (0) | 2012.07.23 |
| Python / CSV파일에서 그룹지어 계산하기 (0) | 2012.05.11 |
| Python / MBR MeSH 파싱하기 (0) | 2012.01.17 |
| PHP / 올바른 코딩, 잘못된 코딩 (0) | 2011.12.15 |