标签:now() 结构化 cal oca mda ftime ctime 北京 时间戳
import time # print(time.time()) # time.sleep(3) # print(help(time)) # print(time.gmtime()) # 中国24个时区 北京+8 结构化时间time.struct_time(tm_year=2020, tm_mon=1, tm_mday=28, tm_hour=1, tm_min=54, tm_sec=52, tm_wday=1, tm_yday=28, tm_isdst=0) # print(time.localtime()) # 本地时间 time.struct_time(tm_year=2020, tm_mon=1, tm_mday=28, tm_hour=10, tm_min=1, tm_sec=56, tm_wday=1, tm_yday=28, tm_isdst=0) # print(help(time.strftime)) # suruct_time = time.localtime() # print(time.strftime("%Y---%m---%d %H:%M:%S",suruct_time)) # 2020---01---28 10:12:17 # print(time.strptime("2020---01---28 10:12:17","%Y---%m---%d %H:%M:%S")) #表现形式,“时间”,“格式” # a = time.strptime("2020---01---28 10:12:17","%Y---%m---%d %H:%M:%S") # print(a.tm_year,a.tm_hour,a.tm_wday) #星期是从零开始的,零代表周一,一周最多为6 # print(time.ctime())# 当前时间 Tue Jan 28 11:08:46 2020 # print(time.ctime(5646465464)) # 指定字符串 Thu Dec 5 22:37:44 2148 # print(help(time.mktime)) # print(time.mktime(time.localtime())) #转换为时间戳 import datetime print(datetime.datetime.now()) #貌似有点长啊2020-01-28 11:16:38.159820
标签:now() 结构化 cal oca mda ftime ctime 北京 时间戳
原文地址:https://www.cnblogs.com/bdua/p/12238213.html