利用Python内置函数获取当前时间
python version 3.4.3
module : time
代码如下:
# -*- charset:utf-8 -*-
import time
#利用内置函数计算当前时间
currentTime = time.time()
totalSeconds = int(currentTime)
currentSecond = totalSeconds % 60
totalMinutes = totalSeconds // 60
currentMinute = totalMinutes % 60
totalHours = totalMinutes // 60
currentHour = totalHours % 24
#获取的总秒数是以格林尼治时间为标准的,北京在东8时区,所以求得的时间要+8小时
print("当前时间是:",(currentHour+8)," : ",currentMinute," : ",currentSecond)