python 通过urllib模块在svn中下载文件

#_*_coding:utf-8_*_

import urllib

def Schedule(a,b,c):
'''
a:已经下载的数据块
b:数据块的大小
c:远程文件的大小
'''
per = 100.0 * a * b / c
if per > 100:
per = 100
print "%.2f%%"% per

 

f=file('a.txt')#文件路径保存
for i in f.readlines():
c=i.strip().split('/')
b='/Python27/a/%s'%''.join(c[-1:])
i=i.decode("gb2312").encode('utf-8')#读取文本中内容后转码
urllib.urlretrieve(i,b,Schedule)

 

posted @ 2016-04-12 09:50  ppppppy  阅读(1074)  评论(0编辑  收藏  举报