There is a requirement that I need to unify the modification time of all excels in the directory. I want to write a python script. At first I naively thought that renaming would be enough, but in fact it is not possible.
Then I found several libraries for operating excel (openpyxl, xlutils), and wanted to open and save them. The result was that either the xlsx format was not supported or the format was not supported. . In short, there are always some flaws in the format, which will destroy the original style. .
So is there any other way? The effect is equivalent to opening and saving this file (excel)
os.utime
shutil.copy
What kind of system is it? If it’s Linux, just touch it directly. You have to go through such trouble
Copy the source file, rename it, and then delete the source file.