from docx import Documentimport osfrom win32com import clientfile_name="D:/BaiduNetdiskDownload/Summary of copywriting"file_list=os.listdir(file_name)data_list=[]for one_file in file_list:dir_file_name=file_name+"/"+one_filedata_list.append(one_file+"\r")if "docx" in dir_file_name:try:data=Document(dir_file_name)data_list+=[i.text.strip()+"\r" for i in data.paragraphs]except:print()else:word = client.Dispatch("Word.Application")# print("Processed files: "+files[0])# open a filetry:doc = word.Documents.Open(dir_file_name)doc.SaveAs("{}x".format(dir_file_name), 12) # 12 means docx formatdoc.Close()os.remove(dir_file_name)except:print("No normal")with open("25.txt","w",encoding="utf-8") as f:f.writelines(data_list)