time 模块
Posted fly10086
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了time 模块相关的知识,希望对你有一定的参考价值。
1 # Author:CallMeV 2 # DATE :2019-11-10 3 # Time : 12:47 4 5 import time 6 print("time.time()is:>>>",time.time()) 7 print("time.strftime()is:>>>",time.strftime("%Y-%m-%d %H:%M:%S",time.gmtime())) 8 print("time.gmtime()is:>>>",time.gmtime()) #UTC 格林尼治时间 9 print("time.localtime()is:>>>",time.localtime()) 10 print("time.ctime()is:>>>",time.ctime()) 11 12 import datetime 13 print("datetime.datetime.now()is:>>>",datetime.datetime.now())
运行结果如下:
1 time.time()is:>>> 1573361892.4201996 2 time.strftime()is:>>> 2019-11-10 04:58:12 3 time.gmtime()is:>>> time.struct_time(tm_year=2019, tm_mon=11, tm_mday=10, tm_hour=4, tm_min=58, tm_sec=12, tm_wday=6, tm_yday=314, tm_isdst=0) 4 time.localtime()is:>>> time.struct_time(tm_year=2019, tm_mon=11, tm_mday=10, tm_hour=12, tm_min=58, tm_sec=12, tm_wday=6, tm_yday=314, tm_isdst=0) 5 time.ctime()is:>>> Sun Nov 10 12:58:12 2019 6 datetime.datetime.now()is:>>> 2019-11-10 12:58:12.421197
以上是关于time 模块的主要内容,如果未能解决你的问题,请参考以下文章