教师节教师代表发言稿干部竞争上岗演讲稿python将多个⽂件合并成⼀个⽂件
生产线英文主要思路是:遍历⽂件夹下⾯的每⼀个⽂件,⼀个个将它们写⼊到⽬标⽂件中
直接上代码
hillbilly>如何跟客户沟通import os
斯洛文尼亚语>angry什么意思meragefiledir = os.getcwd()+'\\en\\labeled'# ⽂件路径,getcwd() 表⽰当前⼯作路径
cha chadocList = os.listdir(meragefiledir)# 将⽂件名存⼊到 list 中
docList.sort()# 对⽂件名进⾏排序
waterboardprint(docList)
fname =open('\\en\\bio',"wb")# 将合并后的内容存⼊到 en ⽂件夹的 bio ⽂件,没有则创建for i in docList:
x =open('en\\labeled\\'+ i,"rb")# 打开列表中的⽂件,读取⽂件内容
fname.ad())# 写⼊新建的log⽂件中
拉丁文在线翻译
x.clo()
fname.clo()