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