回答編集履歴
1
追記
test
CHANGED
@@ -8,8 +8,28 @@
|
|
8
8
|
|
9
9
|
>>> jpg_path = Path(r'D:\python\photo\cloud\jpg\test.jpg')
|
10
10
|
|
11
|
-
>>>
|
11
|
+
>>> jpg_path.parts
|
12
12
|
|
13
13
|
('D:\', 'python', 'photo', 'cloud', 'jpg', 'test.jpg')
|
14
14
|
|
15
|
+
>>>
|
16
|
+
|
17
|
+
>>> jpg_path.parts[-2]
|
18
|
+
|
19
|
+
'jpg'
|
20
|
+
|
21
|
+
>>> jpg_path.parts[-3]
|
22
|
+
|
23
|
+
'cloud'
|
24
|
+
|
25
|
+
>>> jpg_path.parts[-4]
|
26
|
+
|
27
|
+
'photo'
|
28
|
+
|
29
|
+
>>>
|
30
|
+
|
31
|
+
>>> jpg_path.parts[-4:-1]
|
32
|
+
|
33
|
+
('photo', 'cloud', 'jpg')
|
34
|
+
|
15
35
|
```
|