import time , datetime
时间字符串加8小时
timestring = “2019-12-21 10:22:56”
转为时间戳
timestamp = time.mktime(time.strptime(timestring, ‘%Y-%m-%d %H:%M:%S’))
print timestamp # 1576894976.0
datetime_struct = datetime.datetime.fromtimestamp(timestamp)
print type(datetime_struct) #
datetime_obj = (datetime_struct + datetime.timedelta(hours=8))
print datetime_obj # 2019-12-21 18:22:56
datetime_str = datetime_obj.strftime(‘%Y-%m-%d %H:%M:%S’)
print datetime_str # 2019-12-21 18:22:56