Technology Sharing

Progress bar prompt - used in Python program to avoid me mistakenly thinking it has hung up

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Using the Librarytqdm
Please add a description of the image
You can also write something by hand, anyway, anything that can be outputted will do;

Demo from chatgpt

import time
from tqdm import tqdm

# 示例函数,模拟长时间运行的任务
def long_running_task():
    total_steps = 100
    for step in tqdm(range(total_steps), desc="Processing", unit="step"):
        time.sleep(0.1)  # 模拟每步执行时间

if __name__ == "__main__":
    print("任务开始...")
    long_running_task()
    print("任务完成!")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

refer to

tqdm