Python 判断时间是否在 8:00-8:15 之间
import datetime
def is_between_8_to_8_15():
now = datetime.datetime.now().time()
start = datetime.time(8, 0, 0)
end = datetime.time(8, 15, 0)
return start <= now <= end
使用方法:
if is_between_8_to_8_15():
print('当前时间在上午 8 点到 8 点 15 分之间')
else:
print('当前时间不在上午 8 点到 8 点 15 分之间')
原文地址: https://www.cveoy.top/t/topic/oVEU 著作权归作者所有。请勿转载和采集!