Amazing-Python-Scripts
8 строк · 563.0 Байт
1# import datetime library in python
2from datetime import datetime
3# Saves a .txt file with file name
4# as 2020-01-11-10-20-23.txt at current time indicated by now function of datetime library
5with open(datetime.now().strftime("%Y-%m-%d-%H-%M-%S"), "w") as myfile:
6# instead of now i could also initialse with datetime(1999, 12, 12, 12, 12, 12, 342380) to give the time values to datetime constructor
7# Content of the file (it can be any script in python which we want to run at a particular time )
8myfile.write("hii guys ,your Lunch time begins ! ")
9