【发布时间】:2013-12-19 20:22:04
【问题描述】:
以下条件不起作用,知道吗? Python 是否认为上午 8 点属于同一天,所以这种情况是不可能的?
from datetime import datetime, time
now = datetime.now()
now_time = now.time()
if now_time >= time(23,00) and now_time <= time(8,00):
try:
print 'hall light turning on'
except:
print 'Could not connect to Hue gateway'
【问题讨论】:
-
使用
or而不是and
标签: python if-statement time