12345678910111213141516import time# 示例数组,你可以替换为实际的数组data_array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]num = len(data_array)bar_length = 20 # 设定进度条总长度,可根据喜好调整for index, element in enumerate(data_array): i = index + 1 timeflush = 2 # 每处理2个元素刷新一次进度条,可按需调整 if i % timeflush == 0 or i == num: progress_percent = int(i / num * 100) filled_length = int(bar_length * (progress_percent / 100)) bar = "|" + "-" * filled_length + " " * (bar_length - filled_length) + "|" print(f"\r正在加载: {bar} {progress_percent}%", end="") time.sleep(0.1)print()