()
| 11 | import time |
| 12 | |
| 13 | def main(): |
| 14 | # Print the name of the OS |
| 15 | print (os.name) |
| 16 | |
| 17 | # Check for item existence and type |
| 18 | print ("Item exists: " + str(path.exists("textfile.txt"))) |
| 19 | print ("Item is a file: " + str(path.isfile("textfile.txt"))) |
| 20 | print ("Item is a directory: " + str(path.isdir("textfile.txt"))) |
| 21 | |
| 22 | # Work with file paths |
| 23 | print ("Item's path: " + str(path.realpath("textfile.txt"))) |
| 24 | print ("Item's path and name: " + str(path.split(path.realpath("textfile.txt")))) |
| 25 | |
| 26 | # Get the modification time |
| 27 | t = time.ctime(path.getmtime("textfile.txt")) |
| 28 | print (t) |
| 29 | print (datetime.datetime.fromtimestamp(path.getmtime("textfile.txt"))) |
| 30 | |
| 31 | # Calculate how long ago the item was modified |
| 32 | td= datetime.datetime.now() - datetime.datetime.fromtimestamp(path.getmtime("textfile.txt")) |
| 33 | print ("It has been " + str(td) + " since the file was modified") |
| 34 | print ("Or, " + str(td.total_seconds()) + " seconds") |
| 35 | |
| 36 | if __name__ == "__main__": |
| 37 | main() |
no outgoing calls
no test coverage detected