datetime中strftime和strptime用法

from datetime import *
format = "%Y-%m-%d %H:%M:%S"
a=datetime.now()
day=a.day
b=a.replace(day=day+1)
s=b.strftime(format)#datetime类型转化成 string类型
expire_time=datetime.strptime(s, format)#string类型转化成datetime类型
now = datetime.now()
if now<expire_time:
    return True

 

posted @ 2015-06-05 20:24  圆旭  阅读(1047)  评论(0编辑  收藏  举报