teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

追記

2018/09/23 16:07

投稿

katoy
katoy

スコア22328

answer CHANGED
@@ -1,3 +1,17 @@
1
1
  参考情報
2
2
  - Python覚書ファイルの更新日を取得する。
3
- [https://qiita.com/h6rdworker/items/ff061f4c9271460a8bbc](https://qiita.com/h6rdworker/items/ff061f4c9271460a8bbc)
3
+ [https://qiita.com/h6rdworker/items/ff061f4c9271460a8bbc](https://qiita.com/h6rdworker/items/ff061f4c9271460a8bbc)
4
+
5
+ 追記
6
+ カレントフォルダの最新ファイルを求める
7
+ ```python3
8
+ import os
9
+ from pathlib import Path
10
+
11
+ p = Path(".")
12
+ files = list(p.glob("*"))
13
+ file_updates = {file_path: os.stat(file_path).st_mtime for file_path in files}
14
+
15
+ newst_file_path = max(file_updates, key=file_updates.get)
16
+ print(newst_file_path)
17
+ ```