File tree Expand file tree Collapse file tree 2 files changed +15
-42
lines changed Expand file tree Collapse file tree 2 files changed +15
-42
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 12
12
13
13
def main ():
14
14
# Print the name of the OS
15
+ print (os .name )
15
16
16
-
17
17
# Check for item existence and type
18
+ print ("Item exists: {}" .format (path .exists ("textfile.txt" )))
19
+ print ("Item is a file: {}" .format (path .isfile ("textfile.txt" )))
20
+ print ("Item is a directory: {}" .format (path .isdir ("textfile.txt" )))
18
21
19
-
20
22
# Work with file paths
23
+ print ("Item's path is: {}" .format (path .realpath ("textfile.txt" )))
24
+ print ("Item's path and name: {}" .format (
25
+ path .split (path .realpath ("textfile.txt" ))
26
+ ))
21
27
22
-
23
28
# Get the modification time
29
+ t = time .ctime (path .getmtime ("textfile.txt" ))
30
+ print (t )
31
+ print (datetime .datetime .fromtimestamp (path .getmtime ("textfile.txt" )))
24
32
25
-
26
33
# Calculate how long ago the item was modified
34
+ td = datetime .datetime .now () - datetime .datetime .fromtimestamp (path .getmtime ("textfile.txt" ))
35
+ print ("It has been {} since the file was modified" .format (td ))
36
+ print ("Or, {} seconds" .format (td .total_seconds ()))
37
+
27
38
28
-
29
39
if __name__ == "__main__" :
30
40
main ()
You can’t perform that action at this time.
0 commit comments