1.多个txt,merge到同一个txt中的py脚本
#-*- coding: utf-8 -*-
import numpyas np
import os
cwd = os.getcwd()
print (cwd)
txtFile1 = cwd +'\last1.txt'
txtFile2 = cwd +'\last2.txt'
mergeFile2 = cwd +'\mergeTXT.txt'
f =open(mergeFile2,'w',encoding='UTF-8')
for (index1, line1)in enumerate(open(txtFile1,'r',encoding='UTF-8')):
# print index1, line1
for (index2, line2)in enumerate(open(txtFile2,'r',encoding='UTF-8')):
if index1 == index2:
newline = line1 + line2 +'\n'
print(newline)
f.write(newline)
f.close()
网友评论