代码语言:javascript复制
#!/usr/bin/env python
--coding:utf-8--'
Filename:download_file.py
import sys,os
import urllib
def urlcallback(a,b,c):
"""
call back function
a,已下载的数据块
b,数据块的大小
c,远程文件的大小
"""
print "callback"
prec=100.0ab/c
if 100 < prec:
prec=100
print "%.2f%%"%(prec,)
def main(argv):
"""
main
"""
print "start..."
urllib.urlretrieve("<a href="http://jaist.dl.sourceforge.net/project/pydev/pydev/Pydev 1.6.3/org.python.pydev.feature-1.6.3.2010100513.zip">http://jaist.dl.sourceforge.net/project/pydev/pydev/Pydev 1.6.3/org.python.pydev.feature-1.6.3.2010100513.zip"\
,"/tmp/python.pydev.zip"
,urlcallback)
print "end..."
if name=="main":
main(sys.argv[1:])</pre>