def get_current_time():
#将python的datetime转换为unix时间戳
dtime = datetime.datetime.now()
un_time = time.mktime(dtime.timetuple())
#print un_time #1509636609.0
#将unix时间戳转换为python 的datetime
unix_ts = un_time
times = datetime.datetime.fromtimestamp(unix_ts)
#print times
return times #2017-11-02 23:29:45
相关文章
- 10-09get_time