【发布时间】:2014-08-30 20:24:35
【问题描述】:
我正在编写我的 python 脚本来检查 00 和 29 分钟之间的分钟数。
当我的当地时间在下午 6:00 和下午 6:29 之间时,我想知道如何在 python 中查看 00 和 29 的分钟数?
例如:
if (now.strftime("%d") >= "00" and <= "29")
self.getControl(4203).setLabel(time.strftime("%I").lstrip('0') + ':00' + time.strftime("%p"))
else:
self.getControl(4203).setLabel(time.strftime("%I").lstrip('0') + ':30' + time.strftime("%p"))
【问题讨论】:
-
问题不清楚,请改写。
-
显然他想要一个函数,该函数需要一个日期时间并返回最接近它的两个日期时间,它们位于小时或半小时。前任。 f(6:23) 返回 (6:00, 6:29),f(3:47) 返回 (3:30, 3:59)。
-
@Andy 我的问题是我的当地时间是在下午 6:00 到下午 6:30 之间,然后做点什么。请看我的示例代码,你会明白我的意思。
-
@Kevin 是的,你是对的。我需要创建 if 语句来检查时间,看看我是否在下午 6:00 和下午 6:29 之间或等于或在下午 6:30 之后。我不知道如何在 python 中做到这一点。
标签: python python-2.7