python time部分功能

2021-09-22 16:25:24 字數 761 閱讀 6258

import time

# time.time() 返回當前時間的時間戳(1970元年後的浮點數)

# time.localtime() 接收時間戳,並返回當地時間下的元組t

# time.strftime() 把乙個代表時間的元組或者struct_time轉化為格式化的時間字串。

t = time.time() #輸出結果為:1557820668.4665997

t2 = time.localtime(t) #time.struct_time(tm_year=2019, tm_mon=5, tm_mday=14, tm_hour=16, tm_min=1, tm_sec=44, tm_wday=1, tm_yday=134, tm_isdst=0)

print(time.strftime("%y-%m-%d %h:%m:%s",t2))

print(time.strftime("%y-%m-%d %h:%m:%s",time.localtime(time.time())))

# time.sleep(sec) 推至呼叫執行緒的執行,時間暫定sec秒

time.sleep(3)

print("時間暫停3秒")

python time庫功能和使用方法

首先使用time 庫需要import,例如 import time time 庫功能有三個 1.時間處理 2.時間格式化 3.時間計時 時間處理有四個函式 1.time.time 2.time.gmtime 3.time.localtime 4.time.ctime 其中time模組的核心函式tim...

Window h部分函式功能

win環境下 system 函式的作用就是把字串輸入進 cmd裡 例如system echo for example 就和 std cout for,example 的作用相同。至於有多少個選項可以試試system help 這將會輸出所有 cmd命令 include stdafx.h includ...

git的部分功能

1.要git clone 遠端倉庫位址 2.在資料夾中clone的倉庫會有乙個新的資料夾,然後點進去新的資料夾,右鍵git開啟,就可以使用git add git commit m 提交的備註 等相關命令提交到本地倉庫了 等今天寫完 並且git add和git commit提交到本地倉庫之後 然後要g...