文章详情页
python如何不改动文件的情况下修改文件的 修改日期
浏览:319日期: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 images显示的镜像过多,狗眼被亮瞎了,怎么办?2. docker api 开发的端口怎么获取?3. docker镜像push报错4. PHP中的$this代表当前的类还是方法?5. macos - mac下docker如何设置代理6. 如何解决Centos下Docker服务启动无响应,且输入docker命令无响应?7. 老师,flex-shrink: 1; 按视频操作,不会自动缩放8. 前端 - 类到底该如何去命名 .newsList 这种的命名难道真的不是过度语义化吗?~9. sublime-text - sublime text 3中编译python(sublimeREPL),如何仅运行单行/选定部分10. android glide asbitmap 在baseadpter中的问题
排行榜

网公网安备