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. golang - 用IDE看docker源碼時(shí)的小問(wèn)題2. javascript - 請(qǐng)指條明路,angular的$event,在select中卻是undefined?3. 前端 - @media query 使用出現(xiàn)的問(wèn)題?4. 我何時(shí)應(yīng)該在Java中使用JFrame.add(component)和JFrame.getContentPane()。add(component)5. html - css氣泡,實(shí)現(xiàn)“倒三角(不知道算不算三角了)”可透明的。6. 運(yùn)行python程序時(shí)出現(xiàn)“應(yīng)用程序發(fā)生異常”的內(nèi)存錯(cuò)誤?7. docker - 如何修改運(yùn)行中容器的配置8. 利用IPMI遠(yuǎn)程安裝centos報(bào)錯(cuò)!9. phpstudy8.1沒(méi)集成mysql-front10. html5和Flash對(duì)抗是什么情況?

網(wǎng)公網(wǎng)安備