1
각 파일의 * .log 파일에 차이가 기록되고 싶습니다. - 2 개의 전화 번호부 또는 폴더 사이 줄 기준으로 파일 비교.어떻게 파이썬 3.6.1을 사용하여 2 개의 디렉토리/폴더 비교에서 파일 - 투 - 파일 (XML)의 차이를 비교할 수 있습니까?
각 파일의 * .log 파일에 차이가 기록되고 싶습니다. - 2 개의 전화 번호부 또는 폴더 사이 줄 기준으로 파일 비교.어떻게 파이썬 3.6.1을 사용하여 2 개의 디렉토리/폴더 비교에서 파일 - 투 - 파일 (XML)의 차이를 비교할 수 있습니까?
k=0
for i in dirs1:
for j in dirs2:
if i==j:
with open(os.path.join(path1,os.path.basename(i)), 'r') as f1:
with open(os.path.join(path2,os.path.basename(j)), 'r') as f2:
k+=1
print('TC'+str(k)+ ' started...')
print(os.path.join(path1,os.path.basename(i)), '\t',os.path.join(path2,os.path.basename(j)))
out_file.flush()
name1=os.path.basename(i)
name2=os.path.basename(j)
if name1==name2:
diff = difflib.ndiff(f1.readlines(), f2.readlines())
out_file.flush()
testPassed=None
#print lines with difference
for line in diff:
if line.startswith('-') and not(line.startswith('- <ID') or line.startswith('-Created :') or line.startswith('-Name=') or line.startswith('- <Information') or line.startswith('- ,,Date:') or line.startswith('- ,,,')):
testPassed=True
out_file.write(line)
out_file.flush()
elif line.startswith('+') and not(line.startswith('+ <ID') or line.startswith('+Created :') or line.startswith('+Name=') or line.startswith('+ <Information') or line.startswith('+ ,,Date:') or line.startswith('+ ,,,')):
testPassed=True
out_file.write(line)
out_file.flush()
if not testPassed ==True:
print('\tTC'+str(k)+' Passed for: %s\n' %i)
else:
print('\t\t***TC'+str(k)+' Failed for: %s ***\n' %i)
을 차이점 난 디렉토리의 모든 파일에 대한 라인의 차이에 의해 라인이 필요합니다. –