#把datetime转成字符串def datetime_toString(dt): return dt.strftime("%Y-%m-%d-%H")#把字符串转成datetimedef string_toDatetime(string): return datetime.strptime(string, "%Y-%m-%d-%H")#把字符串转成时间戳形式def string_toTimestamp(strTime): return time.mktime(string_toDatetime(strTime).timetuple())#把时间戳转成字符串形式def timestamp_toString(stamp): return time.strftime("%Y-%m-%d-%H", tiem.localtime(stamp))#把datetime类型转成时间戳形式def datetime_toTimestamp(dateTim): return time.mktime(dateTim.timetuple())