Datetime current year and month in Python

后端 未结 7 1171
情话喂你
情话喂你 2020-12-07 21:33

I must have the current year and month in datetime.

I use this:

datem = datetime.today().strftime(\"%Y-%m\")
datem = datetime.strptime(datem, \"%Y-%m         


        
7条回答
  •  既然无缘
    2020-12-07 22:22

    >>> from datetime import date
    >>> date.today().month
    2
    >>> date.today().year
    2020
    >>> date.today().day
    13
    

提交回复
热议问题