This commit is contained in:
27942
2025-10-27 17:13:38 +08:00
parent 50ced0200f
commit 2e291be0e8
2 changed files with 11 additions and 26 deletions

View File

@@ -1,26 +1,11 @@
import time
from tqdm import tqdm
from datetime import datetime
pbar = tqdm(total=30)
# 获取当前时间的分钟数
def get_current_minute():
now = datetime.now()
return now.minute
for i in range(31): # 包含0~30
pbar.n = i # 直接设置进度
pbar.refresh() # 刷新显示
time.sleep(0.2)
# 计算进度
def calculate_progress(minute):
return minute % 30
# 创建进度条
with tqdm(total=30, desc="时间进度", unit="分钟") as pbar:
while True:
current_minute = get_current_minute()
progress = calculate_progress(current_minute)
# 重置进度条并更新到计算出的进度
pbar.reset()
pbar.update(progress)
# 每秒更新一次进度条
time.sleep(1)
pbar.close()