python如何不改動(dòng)文件的情況下修改文件的 修改日期
問(wèn)題描述
有個(gè)需求是我需要把目錄下所有的excel的修改時(shí)間統(tǒng)一,想寫(xiě)個(gè)python腳本,剛開(kāi)始天真的以為重命名就行了,其實(shí)是不行的。然后找了幾個(gè)操作excel的庫(kù)(openpyxl,xlutils),想打開(kāi)然后再保存,結(jié)果要么不支持讀取xlsx的格式,要么。。總之格式上總歸有點(diǎn)瑕疵,會(huì)破壞原來(lái)的樣式。。所以有沒(méi)有其他的辦法,效果相當(dāng)于打開(kāi)再保存一下這個(gè)文件(excel)
問(wèn)題解答
回答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:是什么系統(tǒng)啊,如果是linux,直接touch不就好了,非要這么折騰
回答4:復(fù)制一份源文件再重命名,再刪除源文件.
相關(guān)文章:
1. docker容器呢SSH為什么連不通呢?2. docker api 開(kāi)發(fā)的端口怎么獲取?3. docker網(wǎng)絡(luò)端口映射,沒(méi)有方便點(diǎn)的操作方法么?4. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””5. python - from ..xxxx import xxxx到底是什么意思呢?6. nignx - docker內(nèi)nginx 80端口被占用7. debian - docker依賴(lài)的aufs-tools源碼哪里可以找到啊?8. ddos - apache日志很多其它網(wǎng)址,什么情況?9. 請(qǐng)教各位大佬,瀏覽器點(diǎn) 提交實(shí)例為什么沒(méi)有反應(yīng)10. angular.js - ng-grid 和tabset一起用時(shí),grid width默認(rèn)特別小
