1 .datetime转1970年秒数
import time,datetime timeDateStr="2014-07-29 00:00:00" time1=datetime.datetime.strptime(timeDateStr,"%Y-%m-%d %H:%M:%S") secondsFrom1970=time.mktime(time1.timetuple())
2.1970年秒数转datetime
import time,datetime
timeArray = time.localtime(1462482700)#1970秒数
print(timeArray)
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
datetime1=datetime.datetime.strptime(otherStyleTime, "%Y-%m-%d %H:%M:%S")