文章詳情頁
python如何不改動文件的情況下修改文件的 修改日期
瀏覽:105日期: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. centos - apache配置django報錯:cannot be loaded as Python modules2. html5 - 使用angular中,圖片上傳功能中選擇多張圖片是怎么實現的?有什么好的思路嗎?3. python - flask jinjia2 中怎么定義嵌套變量4. python - Django問題 ’WSGIRequest’ object has no attribute ’user’5. 數據庫 - mysql boolean型無法插入true6. javascript - jquery選擇的dom元素如何更新?7. javascript - H5頁面無縫輪播8. .......9. javascript - URL中有#號如何來獲取參數啊? nodejs10. MYSQL 的 SELECT 語句中如何做到判斷字段為空
排行榜
