回答編集履歴

1

追記

2018/09/23 16:07

投稿

katoy
katoy

スコア22324

test CHANGED
@@ -3,3 +3,31 @@
3
3
  - Python覚書ファイルの更新日を取得する。
4
4
 
5
5
  [https://qiita.com/h6rdworker/items/ff061f4c9271460a8bbc](https://qiita.com/h6rdworker/items/ff061f4c9271460a8bbc)
6
+
7
+
8
+
9
+ 追記
10
+
11
+ カレントフォルダの最新ファイルを求める
12
+
13
+ ```python3
14
+
15
+ import os
16
+
17
+ from pathlib import Path
18
+
19
+
20
+
21
+ p = Path(".")
22
+
23
+ files = list(p.glob("*"))
24
+
25
+ file_updates = {file_path: os.stat(file_path).st_mtime for file_path in files}
26
+
27
+
28
+
29
+ newst_file_path = max(file_updates, key=file_updates.get)
30
+
31
+ print(newst_file_path)
32
+
33
+ ```