How do you add datetime to a logfile name?

后端 未结 7 636
孤街浪徒
孤街浪徒 2020-12-29 19:42

When I create my logfile, I want the name to contain the datetime.

In Python you can get the current datetime as:

>>> from datetime import da         


        
相关标签:
7条回答
  • 2020-12-29 20:16

    Yes. Have a look at the datetime API, in particular strftime.

    from datetime import datetime
    print datetime.now().strftime("%d_%m_%Y")
    
    0 讨论(0)
提交回复
热议问题