文章详情页
python如何不改动文件的情况下修改文件的 修改日期
浏览:162日期: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. docker容器呢SSH为什么连不通呢?2. docker api 开发的端口怎么获取?3. docker网络端口映射,没有方便点的操作方法么?4. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””5. python - from ..xxxx import xxxx到底是什么意思呢?6. nignx - docker内nginx 80端口被占用7. debian - docker依赖的aufs-tools源码哪里可以找到啊?8. ddos - apache日志很多其它网址,什么情况?9. 请教各位大佬,浏览器点 提交实例为什么没有反应10. angular.js - ng-grid 和tabset一起用时,grid width默认特别小
排行榜
