相关疑难解决方法(0)

Python时差

我有两个时间对象.

time.struct_time(tm_year=2010, tm_mon=9, tm_mday=24, tm_hour=19, tm_min=13, tm_sec=37, tm_wday=4, tm_yday=267, tm_isdst=-1)

time.struct_time(tm_year=2010, tm_mon=9, tm_mday=25, tm_hour=13, tm_min=7, tm_sec=25, tm_wday=5, tm_yday=268, tm_isdst=-1)
Run Code Online (Sandbox Code Playgroud)

我想要有这两者的区别.我怎么能这样做?我只需要几分钟和几秒钟,以及这两者的持续时间.

python time datetime

21
推荐指数
2
解决办法
4万
查看次数

查看日期时间之间是否已经过了24小时 - Python

我有以下方法:

# last_updated is a datetime() object, representing the last time this program ran
def time_diff(last_updated):
    day_period = last_updated.replace(day=last_updated.day + 1, 
                                      hour=1,
                                      minute=0,  
                                      second=0,
                                      microsecond=0)
    delta_time = day_period - last_updated
    hours = delta_time.seconds // 3600
    # make sure a period of 24hrs have passed before shuffling
    if hours >= 24:
        print "hello"
    else:
        print "do nothing"
Run Code Online (Sandbox Code Playgroud)

我想知道从那以后24小时过去了last_updated,我怎么能这样做last_updated呢?

python timezone datetime

14
推荐指数
1
解决办法
9016
查看次数

标签 统计

datetime ×2

python ×2

time ×1

timezone ×1