1 step = 1 2 max_steps = len(letter) 3 max_arrow = 60 4 5 6 for str_le in letter: 7 8 #进度条 9 max_steps = len(letter) 10 max_arrow = 60 11 step = 0 12 num_arrow = int(float(step*1.0) * max_arrow / max_steps) # 计算显示多少个'>' 13 num_line = max_arrow - num_arrow # 计算显示多少个'-' 14 percent = step * 100.0 / max_steps # 计算完成进度,格式为xx.xx% 15 process_bar = 'Waiting:[' + '#' * num_arrow + '-' * num_line + ']' + '%.02f' % percent + '%' # 带输出的字符串,' '表示不换行回到最左边 16 print(' ' + process_bar,end = '') 17 step = step + 1