-
<PYTHON>파싱결과 비교(contents) --> 파일 저장Flower in my dev/Python 2015. 5. 29. 09:571234567891011121314151617181920212223242526272829303132333435import osnFile = 'flower_new.txt'oFile = 'flower_old.txt'nRead = open(nFile, 'r')oRead = open(oFile, 'r')nList = nRead.readlines()oList = oRead.readlines()fResult = open('flower_result.txt', 'w')cnt = 0if len(nList) == len(oList):fResult.write("[Same Length]" + '\n')for n in nList:o = oList[cnt]if n == o:fResult.write(">>Equal, Line Number : " + str(cnt) + '\n')else:fResult.write("!!!!Different, Line Number : " + str(cnt) + '\n')cnt += 1else:cnt = 0fResult.write("[Not Same Length]" + '\n')for n in nList:o = oList[cnt]if n == o:fResult.write(">>Equal, Line Number : " + str(cnt) + '\n')else:fResult.write("!!!!Different, Line Number : " + str(cnt) + '\n')cnt += 1fResult.close()
cs 파싱된 결과를 전체 라인을 읽어서
라인별로 같은지 비교하여 파일에 저장 스크립트
'Flower in my dev > Python' 카테고리의 다른 글
<PYTHON>[ConfigParser] (0) 2015.05.29 <PYTHON>파싱결과 비교(split count) --> 파일 저장 (0) 2015.05.29 <PYTHON>디렉토리 검색 및 xml 파싱 --> 파일 저장 (0) 2015.05.29 <PYTHON>[shutil] (0) 2015.05.28 <PYTHON>[StringIO] (0) 2015.05.28