import shutil
import os
path = "E:\\in\\" #文件夹操作目录
path2 = "E:\\out\\" #文件夹输出目录
files= os.listdir(path) #得到文件夹下的所有文件名称,处理整个文件目录下面的所以文件
for file in files:
file_data = ''
with open(path+file, 'r',encoding='utf-8') as f:
for line in f.readlines():
line = line.strip()
if (len(line) > 1): ## 判断条件,过滤空格
file_data += line + '\r\n'
with open(path2+file, "w", encoding="utf-8") as f:
f.write(file_data)
print(path2+file+'文件创建成功!')
#截取文件内容
#idx = line.find("orderNo")
#if(idx != -1):
# print(line[idx+9:idx+26])
#data += line