千锋 2018-05-22
实例如下所示:
import time,datetime def gettime(): for x in range(24): a = datetime.datetime.now().strftime("%Y-%m-%d")+" %2d:00:00"%x timeArray = time.strptime(a, "%Y-%m-%d %H:%M:%S") timeStamp = int(time.mktime(timeArray)) print(timeStamp) if __name__ == "__main__": gettime()