文章詳情頁
python如何不改動文件的情況下修改文件的 修改日期
瀏覽:257日期: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 hub上有些鏡像的tag被標記““This image has vulnerabilities””2. boot2docker無法啟動3. docker-compose中volumes的問題4. nignx - docker內nginx 80端口被占用5. java - SSH框架中寫分頁時service層中不能注入分頁類6. docker安裝后出現Cannot connect to the Docker daemon.7. dockerfile - 為什么docker容器啟動不了?8. docker容器呢SSH為什么連不通呢?9. 關于docker下的nginx壓力測試10. docker images顯示的鏡像過多,狗眼被亮瞎了,怎么辦?
排行榜

網公網安備