用tqdm包实现进度条:

tqdm基本用法:

from time import sleep
from tqdm import tqdm
for i in tqdm(range(10000)):
     sleep(0.01)

tqdm更多用法:https://blog.csdn.net/langb2014/article/details/54798823

python3 不换行打印,多用于进度条 process bar

    process = 0  # process bar
    for i in user:  
        process += 1
        print("\rProcess: %f " % (process/len(user)), end='')
        process_code()

更多样式:

    proc += 1
    print('\r loading... %.2f %%' % (process/len(user)*100), end='')

python2:

对于py2来讲,主要起作用的是末尾的逗号:

    print '\r loading... {:.3f}' .format( (float(proces))/len(user)*100 ) ,
  print('%.3f' % 1.12345678)     # Let's take 3 decimal places
  print'{:.3f}'.format(3.14159)

相关文章:

  • 2021-06-11
  • 2021-12-27
  • 2022-12-23
  • 2021-08-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
  • 2021-06-14
  • 2021-10-10
  • 2021-11-08
相关资源
相似解决方案