How to set a variable to be “Today's” date in Python/Pandas

后端 未结 8 2247
醉话见心
醉话见心 2020-12-23 19:35

I am trying to set a variable to equal today\'s date.

I looked this up and found a related article:

Set today date as default value in the model

Howe

8条回答
  •  无人及你
    2020-12-23 20:16

    If you want a string mm/dd/yyyy instead of the datetime object, you can use strftime (string format time):

    >>> dt.datetime.today().strftime("%m/%d/%Y")
                       # ^ note parentheses
    '02/12/2014'
    

提交回复
热议问题