python中对日期对象的处理

两篇值得看的博客:

https://www.cnblogs.com/huigebj/p/11259449.html

https://blog.csdn.net/zzddada/article/details/102822337

字符串 -> 日期

from datetime import datetime

setTime = '2015-04-16'
now = datetime.strptime(setTime, "%Y-%m-%d")

日期时间段

from datetime import timedelta
delta = datetime.timdelta(days=1)  # 用来做加减日期

日期 -> 字符串

now.strptime("%Y-%m-%d")
posted @ 2021-09-05 13:25  nerd`  阅读(17)  评论(0编辑  收藏  举报