繁体   English   中英

从time.struct_time对象检查分钟

[英]Check minutes from time.struct_time object

我想检查time.struct_time对象以查看是否有30分钟的分钟数,然后执行一些操作。

当我尝试这个:

one_hour_half = str(self.getControl(346).getLabel())
epg_time_3 = time.strptime(one_hour_half, '%I:%M%p')
program_stop_time = time.strptime(prog_stop_clock, '%I:%M%p')


if program_stop_time > epg_time_3:
   if int(current_time) >= 30 and int(current_time) >= 59:
       if epg_time_3 == '30':
          print "you are here, now let do something..."

epg_time_3结果:

time.struct_time(tm_year=1900, tm_mon=1, tm_mday=1, tm_hour=17, tm_min=30, tm_sec=0, tm_wday=0, tm_yday=1, tm_isdst=-1)

它不会让我通过if epg_time_3语句。 那是因为我使用的是time.struct_time ,所以我使用变量one_hour_half ,该字符串显示为5:30PM 我想知道如何使用time.struct_time对象epg_time_3来查看是否有30分钟?

只需使用epg_time_3.tm_min来获取分钟字段:

if epg_time_3.tm_min == 30:
    print "you are here, now let do something..."

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM