文章详情页
python如何不改动文件的情况下修改文件的 修改日期
浏览:216日期: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. css3 - 一个关于CSS雪碧图的问题2. Docker for Mac 创建的dnsmasq容器连不上/不工作的问题3. docker-machine添加一个已有的docker主机问题4. redis编译报错:cannot find -lgcc_s5. docker镜像push报错6. 如何解决Centos下Docker服务启动无响应,且输入docker命令无响应?7. 前端 - webpack如何打包script标签引入的代码8. mac里的docker如何命令行开启呢?9. angular.js - 如何在指令里使用ng-click10. node.js - antdesign怎么集合react-redux对input控件进行初始化赋值
排行榜

网公网安备