Hi I want my python script to print minute wise log so I want variable b to be replaced but its not happening and log file generating with name %(b)s_python.log
Please Help !
import logging, datetime
a=datetime.date.today()
b=a.strftime("%y_%B_%a_%H%M")
print(b)
logging.basicConfig(filename="D:\%(b)s_python.log",level=logging.DEBUG,format="%(levelname)s %(asctime)s-%(message)s")
logging.debug("Hi Sudhirrrrrrrrr")
datetime.date.today() does not give you the current hour and minute.
import logging, datetime
a=datetime.datetime.now()
b='D:\\'+a.strftime("%y_%B_%a_%H%M")+'s_python.log'
print(b)
logging.basicConfig(filename=b,level=logging.DEBUG,format="%(levelname)s %(asctime)s-%(message)s")
logging.debug("Hi Sudhirrrrrrrrr")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.