import time
print time.time()
输出的结果是(单位:s):
1395421406.39
x = time.localtime(x)
x = time.strftime('%Y-%m-%d %H:%M:%S',x)
print x
输出的结果是:
2014-03-22 01:04:58
打印当前时间
print (datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S'))