# import time # 返回時間戳 # print(time.time()) #返回時間戳 # print(time.gmtime()) #返回utc時間戳 # print(time.localtime(time.time()-86400)) #返回當地的時間戳 # print(time.strftime("%Y-%m-%d",time.localtime())) #將struct_time轉為字符串 # print(time.mktime(time.localtime())) #將struct_time 轉為時間惟 # print(time.strptime('2016-03-12','%Y-%m-%d')) #將字符串,轉為struct_time對象 # print(time.ctime()) #返回當前時候 # time.sleep(4) #休眠幾秒 # import datetime # t=datetime.datetime.date() # print(t) # t=datetime.datetime.now() # print(t.replace(2014)) #將時間做一個更改 # # import json # # dic={"name":"zhilei",'age':10} # # con=json.dumps(dic) # # print(con,type(con)) # # string='{"name":zhilei","age":20}' # # print(json.loads(string)) # import json # string='{"name":"zhilei","age":"10"}' # t=json.loads(string) # print(t,type(t)) # import json # string='{"name":"zhilei","age":"10"}' # con=json.dump(string,open("db.txt","w",encoding='utf-8')) # con=json.load(open("db.txt",'r',encoding='utf-8')) # print(con,type(con)) # import sys # print(sys.path,type(sys.path)) import time import datetime # print(datetime.date.today()) #輸出當前日期 # print(datetime.date.fromtimestamp(time.time())) #將時間戳轉換為日期 # print(datetime.date.) # cur_time=datetime.datetime.now()
import time # 返回時間戳 print(time.time()) #返回時間戳 print(time.gmtime()) #返回utc時間戳 print(time.localtime(time.time()-86400)) #返回當地的時間戳 print(time.strftime("%Y-%m-%d",time.localtime())) #將struct_time轉為字符串 print(time.mktime(time.localtime())) #將struct_time 轉為時間惟 print(time.strptime('2016-03-12','%Y-%m-%d')) #將字符串,轉為struct_time對象