import os
def saveFile(filename, content):
f = open(filename, "w", encoding="utf-8")
f.write(content)
def combinetxt(rootdir,filename):
f = open(rootdir+filename, "w",encoding="utf-8")#创建文件
list = os.listdir(rootdir) #枚举文件夹下所有文件
for i in range(0,len(list)):#遍历
path = os.path.join(rootdir,list[i])#完整路径
if os.path.isfile(path):#如果是文件
content = readFile(path)#读取所有
f.write("*****************************")
f.write(content)#写入
f.close();#关闭
def start():
combinetxt("D:/t1","mygzcj.txt")
combinetxt("D:/t2","mygzwyb.txt")
start()