- Read the guideline before start
Write an app that will create 1 file every 1 second in the current working directory (project root).
- File name must be in the following format:
app-{hours}_{minutes}_{seconds}.log. - File content must be a timestamp of this operation (example: 2007-06-29 13:49:40).
- The app must print to console timestamp and newly created file name when it completes file creation successfully.
- The app must run forever until you terminate the process.
It can be relevant here to use:
datetime.now()from moduledatetimesleep()from moduletime
Example:
# Output:
# ...
# 2020-01-01 14:10:07 app-14_10_7.log
# 2020-01-01 14:10:08 app-14_10_8.log
# 2020-01-01 14:10:09 app-14_10_9.log
# ...
with open("app-14_10_7.log", "r") as f:
print(f.read())
# 2020-01-01 14:10:07Important: to import datetime use the following syntax:
from datetime import datetimeDo not use this notation:
import datetime