How to get the last day of the month?

后端 未结 30 2602
迷失自我
迷失自我 2020-11-22 06:13

Is there a way using Python\'s standard library to easily determine (i.e. one function call) the last day of a given month?

If the standard library doesn\'t support

30条回答
  •  长情又很酷
    2020-11-22 07:08

    if you are willing to use an external library, check out http://crsmithdev.com/arrow/

    U can then get the last day of the month with:

    import arrow
    arrow.utcnow().ceil('month').date()
    

    This returns a date object which you can then do your manipulation.

提交回复
热议问题