Time

Time

例子:

def ts2HMS(ts):
    return time.strftime('%Y-%m-%d', time.localtime(ts))

def HMS2ts(date):
    return int(time.mktime(time.strptime(date, '%Y-%m-%d')))

def ts2HMS_1(ts):
    return time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(ts))
def check_main(start,end,DAY_NUM):
'''
输入数据:
start:开始日期,格式“年-月-日”
end:结束日期,格式“年-月-日”
'''
start_time = time.time()
day = (HMS2ts(end)-HMS2ts(start))/(24*60*60)
   print day #day=26
if __name__ == '__main__':
#read_mongo()
start = '2018-05-01'
end = '2018-05-27'

猜你喜欢

转载自www.cnblogs.com/zhongbokun/p/9105399.html