跟踪循环中的完成状态

时间:2012-03-11 11:08:33

标签: python

在这个循环中,我期待的输出是'。'在下载元组列表中的每个url后打印。这个想法是一种进度条,告诉我脚本没有崩溃或任何东西。但是在运行时,所有'。'都会在所有文件下载后打印在一起。为什么呢?

for tuple in tuples:
    urllib.urlretrieve(tuple[0],'/media/aux1/pythonary/getxkcd_files/strip'+str(number))
    print'.',
    hypertext='<h2>'+tuple[2]+'  xkcd no.-'+str(number)+'</h2><p><img src="getxkcd_files/strip'+str(number)+'" title="'+tuple[1]+'"/></p>'
    f.write(hypertext)
    number+=1

0 个答案:

没有答案
相关问题