猫史档案馆


【Python作品分享】2020-08-06-文件对比【求助帖】

用户:尤里卡突袭者机甲尤里卡突袭者机甲查看:71 回复:0 评论:0 创建时间:2020-08-07T18:14:08


【作品展示】

center_image

 

【作品介绍】

没有什么功能,随便发一下而已

 

【作品源代码】

import SeanDef
import time

start = time.time()

aFile = open('C:\\Users\\Xiao\\Desktop\\temp\\1.txt')
bFile = open('C:\\Users\\Xiao\\Desktop\\temp\\2.txt')

aFileList = []
while True:
    strA = aFile.readline()
    if strA:
        aFileList.append(strA)
    else:
        break

bFileList = []
while True:
    strB = bFile.readline()
    if strB:
        bFileList.append(strB)
    else:
        break    

aFile.close
bFile.close
    
cFile = SeanDef.ListCompare(aFileList,bFileList,0)
cFile.pop(0)
with open('C:\\Users\\Xiao\\Desktop\\temp\\3.txt', 'w') as f:
    for i in range(len(cFile)):
        f.write(str(cFile[i]))
        print(i + 1,'.',cFile[i])
end = time.time()
print('程序共执行了{}秒'.format(end - start))

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页