Skip to content

mate-academy/py-create-file-every-second

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Create a file every second

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 module datetime
  • sleep() from module time

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:07

Important: to import datetime use the following syntax:

from datetime import datetime

Do not use this notation:

import datetime

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages