#!/usr/bin/python#Filename: bidui.py#_*_coding:utf-8_*_import glob, os, re ,os.path,datetime path_a = 'e:\\case\\' path_b = 'e:\\1\\' a_files = glob.glob('%s\\*' % path_a) b_files = glob.glob('%s\\*' % path_b)flie3 = open('testresult.txt', 'a') # open for 'w'ritingfor f in a_files:file_name = os.path.basename(f) file_name_in_folder_b = re.subn(r'\d{8}_\d{2}_\d{2}_\d{2}_', '', file_name) full_path = '%s\\%s' % (path_b, file_name_in_folder_b)full_patha = '%s\\%s' % (path_a, file_name)print (file_name)if full_path in b_files:file_in_a = open(full_patha, 'r')line2 = file_in_a.readline()file_in_b = open(full_path, 'r')line = file_in_b.readline()while True: if len(line) == 0 and len(line2) == 0: break if line == line2:flie3.write('pass')else:print ('failed')flie3.write('fail')file_in_a.close()file_in_b.close()flie3.close()这是我写的一段文本比对程序 用了比对2个文件的内容的结果循环到 if line == line2:flie3.write('pass')
添加回答
举报
0/150
提交
取消