time模块
import time # print(time.time()) #返回时间戳 # print(time.localtime()) #返回元组形式 返回当地时间 # print(time.gmtime()) #返回元组形式 返回utc时区 # print(time.timezone) # print(time.gmtime(1540730812)) #将时间戳转换为元组形式 # x = time.localtime() # print(x) # print(time.mktime(x)) #将元组形式转换为时间戳 # # print(x.tm_year) # print(time.strftime("%Y-%m-%d %H:%M:%S",x)) # convert tuple to str(自定义) # print(time.strptime('2018-10-28 21:09:51',"%Y-%m-%d %H:%M:%S")) #convert str to tuple # print(time.asctime()) #convert tuple to str(固定格式) # print(time.ctime()) #convert second to str(固定格式) import datetime print(datetime.datetime.now()) #现在的时间