How to perform arithmetic operation on a date in Python?

后端 未结 1 413
孤独总比滥情好
孤独总比滥情好 2020-12-08 04:18

I have a date column in csv file say Date having dates in this format 04/21/2013 and I have one more column Next_Day. In Next_Da

相关标签:
1条回答
  • 2020-12-08 04:51

    Using datetime.timedelta

    >>> import datetime
    >>> s = '04/21/2013'
    >>> d = datetime.datetime.strptime(s, '%m/%d/%Y') + datetime.timedelta(days=1)
    >>> print(d.strftime('%m/%d/%Y'))
    04/22/2013
    
    0 讨论(0)
提交回复
热议问题