import
urllib
def hook(a,b,c): # 回调函数
tem = 100.0 * a * b / c
if tem > 100 :
tem = 100
print ' %.2f%% ' % tem
url = " http://192.168.102.42/www/ "
path = " d:\\1.txt "
urllib.urlretrieve(url, path, hook) # 下载html
f = urllib.urlopen("xxx")
print f.read() # 类似于文件操作 readlines, readline
def hook(a,b,c): # 回调函数
tem = 100.0 * a * b / c
if tem > 100 :
tem = 100
print ' %.2f%% ' % tem
url = " http://192.168.102.42/www/ "
path = " d:\\1.txt "
urllib.urlretrieve(url, path, hook) # 下载html
f = urllib.urlopen("xxx")
print f.read() # 类似于文件操作 readlines, readline