How to modify the modification date of a file in python without changing the file
滿天的星座
滿天的星座 2017-06-22 11:51:55
0
4
1033

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)

滿天的星座
滿天的星座

reply all(4)
漂亮男人

os.utime

Help on built-in function utime in module posix:

utime(...)
    utime(path, (atime, mtime))
    utime(path, None)

    Set the access and modified time of the file to the given values.  If the
    second form is used, set the access and modified times to the current time.
ringa_lee

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template