You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB

2 years ago
# -*- coding: utf-8 -*-
"""
@Time : 2023/3/10 17:45
@Author :
@FileName:
@Software:
@Describe:
"""
import os
file = './data/10235513_大型商业建筑人员疏散设计研究_沈福禹/查重txt'
path_list = []
for root, dirs, files in os.walk(file):
for file in files:
path = os.path.join(root, file)
path_list.append(path)
for path in path_list:
with open(path, encoding="utf-8") as f:
text = f.read()
path_dan_list = path.split("\\")
root_path = path_dan_list[0]
file_path = path_dan_list[1]
root_pathdan_list = root_path.split("/")
root_pathdan_list = root_pathdan_list[:-1]
print(root_pathdan_list)
text_list = text.split("@@@@@@@@@@")
text_zhengwen = text_list[-1]
text_list = [i.lstrip("\n") for i in text_list[:-1]]
print(text_list)
text_zhengwen = text_zhengwen.strip().replace("\n", "").replace(" ", "").replace("", "\n")
text_list = text_list + [text_zhengwen]
text_str = "@@@@@@@@@@".join(text_list)
path_new = "/".join(root_pathdan_list + ["查重txt_new", file_path])
with open(path_new, "w") as f:
f.write(text_str)
f.close()