Example need to extract certain company employee details from list of all company employees and save it in new folder, I know to read the files from folder.
fvar=open(r'D:\Employee Details .txt','r')
res=fvar.readlines()
fvar.close()
print(res)
I guess you want to save the details in a new txt file in a specific folder. So you have to expand your Code with something like this:
newfile =open("C:/MyFolder/new.txt",'w')
for item in res:
newfile.write(item)
newfile.close
This is, because your res variable is a list. And you have to iterate through the list and write every single item.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.