标签:时间格式 strftime 转发 ftime mil font time() 现在 time模块
#!/usr/bin/env python
#__author: hlc
#date: 2019/6/7
import time
# print(help(time)) # time 帮助信息
# print(time.time()) # 1559884209.677806 # 打印时间戳 从1970年到现在的秒
# time.sleep(3)
# print(time.process_time()) # 替代clock
# print(time.perf_counter()) # 替代clock
# print(time.gmtime()) # 结构化时间;标准时间;time.struct_time(tm_year=2019, tm_mon=6, tm_mday=7, tm_hour=5, tm_min=24, tm_sec=54, tm_wday=4, tm_yday=158, tm_isdst=0)
# print(time.localtime()) # 本地时间;time.struct_time(tm_year=2019, tm_mon=6, tm_mday=7, tm_hour=13, tm_min=26, tm_sec=22, tm_wday=4, tm_yday=158, tm_isdst=0)
# sturct_time = time.localtime()
# print(time.strftime("%Y--%m--%d %H:%M:%S",sturct_time)) # 2019--06--07 13:34:23
# print(time.strptime("2019--06--07 13:34:23","%Y--%m--%d %H:%M:%S")) # 转换为结构化时间;time.struct_time(tm_year=2019, tm_mon=6, tm_mday=7, tm_hour=13, tm_min=34, tm_sec=23, tm_wday=4, tm_yday=158, tm_isdst=-1)
# a = time.strptime("2019--06--07 13:34:23","%Y--%m--%d %H:%M:%S")
# print(a.tm_year) # 取出年
# print(a.tm_hour) # 取小时
# print(time.ctime(1)) # 把时间戳转发成时间格式;Thu Jan 1 08:00:01 1970
# print(time.ctime(1935324587)) # Wed Apr 30 22:09:47 2031
# print(time.mktime(time.localtime())) # 1559886420.0 ;把时间转换为时间戳
# import datetime
# print(datetime.datetime.now()) # 2019-06-07 13:48:55.931961
标签:时间格式 strftime 转发 ftime mil font time() 现在 time模块
原文地址:https://www.cnblogs.com/hlc-123/p/10988079.html