文章詳情頁
python如何不改動文件的情況下修改文件的 修改日期
瀏覽:175日期:2022-06-28 09:34:21
問題描述
有個需求是我需要把目錄下所有的excel的修改時間統(tǒng)一,想寫個python腳本,剛開始天真的以為重命名就行了,其實是不行的。然后找了幾個操作excel的庫(openpyxl,xlutils),想打開然后再保存,結(jié)果要么不支持讀取xlsx的格式,要么。。總之格式上總歸有點瑕疵,會破壞原來的樣式。。所以有沒有其他的辦法,效果相當(dāng)于打開再保存一下這個文件(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:是什么系統(tǒng)啊,如果是linux,直接touch不就好了,非要這么折騰
回答4:復(fù)制一份源文件再重命名,再刪除源文件.
相關(guān)文章:
1. nignx - docker內(nèi)nginx 80端口被占用2. docker - 如何修改運行中容器的配置3. python3.x - python連oanda的模擬交易api獲取json問題第五問4. node.js - 我是一個做前端的,求教如何學(xué)習(xí)vue,node等js引擎?5. java - SSH框架中寫分頁時service層中不能注入分頁類6. angular.js - angular內(nèi)容過長展開收起效果7. 為什么我ping不通我的docker容器呢???8. docker-machine添加一個已有的docker主機問題9. javascript - js代碼獲取驗證碼倒計時問題10. 關(guān)于docker下的nginx壓力測試
排行榜

熱門標(biāo)簽