DemoPublic/Common/打印百分比进度.md

343 B

打印百分比进度

#include <iostream>
#include <unistd.h>

for(int i=0; i<100; i++)
{
    cout<<flush<<'\r'<<"Writed: "<<i+1<<"/"<<100;
    usleep(200000);
}
cout<<endl;
for i in range(0, 99):
    print('\rWrited: %.1f%%'%(100*i/100), end = '')
    sys.stdout.flush()
#
print('\rWrited: %.1f%%'%(100*100/100))