In fact, if you simply search for files, you don’t need regular expressions. If you use the files in the folder, you can use the glob module to get a list of file names, such as
After getting the list, you can traverse the list and perform the processing you want
for i in file_list:
old_fileName = i
new_fileName = i + '.tmp'
#另存为:
shutil.copy(old_fileName, new_fileName)
with open(new_fileName, 'r+') as f:
#光标移动到末尾
f.seek(0,2)
f.write('\nwrite something')
#f.flush()
In fact, if you simply search for files, you don’t need regular expressions. If you use the files in the folder, you can use the
glob
module to get a list of file names, such asAfter getting the list, you can traverse the list and perform the processing you want
Can additionally process and save files