Tiem 庫是Python中處理時間的標(biāo)準(zhǔn)庫,當(dāng)然Python 中含有豐富的第三方庫,今天我了解到了 Python 中的 Time 庫 的使用 我們可以使用time庫來獲取系統(tǒng)的時間。
我們 可以在程序中 使用 import <庫名>? 來導(dǎo)入 time 庫 有點兒像 C/C++ 中的 include 一樣
Time 庫提供了三種獲取系統(tǒng)時間的方式? time()? 得到系統(tǒng)的時間戳是一個浮點數(shù)、 ctime()? 返回系統(tǒng)時間 返回格式為人易讀的格式? gmtime() 返回系統(tǒng)時間返回格式為字符串形式 一般在程序中使用可直接獲取當(dāng)前時間的字符串形式? 如:

.............
#進(jìn)度條實例
import time
def Fast_Wavy(x):
? ? inder = pow(x+(1-x)/2,8)
? ? return inder
scale = 50
print(" 執(zhí)行開始 ".center(scale//2,'-'))
start = time.perf_counter()
for i in range(scale+1):
? ? a = '*' * i
? ? b = '.' * (scale - i)
? ? c = (i/scale) * 100
? ? dur = time.perf_counter() - start
? ? print("\r{:^3.0f} % [{}->{}] {:.2f}s".format(c,a,b,dur),end = "")
? ? time.sleep(0.1)
print("? Over? ")