下面的代码为我提供了每20次迭代的0%,而不是我希望它显示的实际百分比。
n=100
for i in range(n):
if i% 20 ==0:
print str(i/n*100) + '%, Progress'结果:
0%, Progress
0%, Progress
etc.....我一定是错过了一些很简单的东西。谢谢。
发布于 2016-10-03 11:37:31
将除法改为i/(float)n*100,以便python解释器将结果的输出格式化为小数点。
https://stackoverflow.com/questions/39830581
复制相似问题