Demo downloads an mp3 file from a specified url and displays the download progress percentage during the download process
#encoding=utf-8 import urllib import sys def cbk(a,b,c): per = 100.0*a*b/c if per >100: per=100 def cls(str): return '\r'*len(str) out='%.2f%%'%per sys.stdout.write(u'下载进度:') sys.stdout.write(out) sys.stdout.write(cls(out)) url="" urllib.urlretrieve(url,'download_123.mp3',cbk)