文章详情页
python如何不改动文件的情况下修改文件的 修改日期
浏览:256日期:2022-06-28 09:34:21
问题描述
有个需求是我需要把目录下所有的excel的修改时间统一,想写个python脚本,刚开始天真的以为重命名就行了,其实是不行的。然后找了几个操作excel的库(openpyxl,xlutils),想打开然后再保存,结果要么不支持读取xlsx的格式,要么。。总之格式上总归有点瑕疵,会破坏原来的样式。。所以有没有其他的办法,效果相当于打开再保存一下这个文件(excel)
问题解答
回答1: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.回答2:
shutil.copy
回答3:是什么系统啊,如果是linux,直接touch不就好了,非要这么折腾
回答4:复制一份源文件再重命名,再删除源文件.
相关文章:
1. boot2docker无法启动2. java - SSH框架中写分页时service层中不能注入分页类3. docker安装后出现Cannot connect to the Docker daemon.4. 关于docker下的nginx压力测试5. node.js - antdesign怎么集合react-redux对input控件进行初始化赋值6. 老师,按tab键不起作用怎么回事7. javascript - 在typescript中如何动态export8. html - input中radio为什么多选9. javascript - js如何获取app保存的TOKEN?10. javascript - 怎么用空白DIV填充的方法解决列表数据过多的问题?
排行榜

网公网安备