#!/usr/bin/env python #-*-coding:utf-8-*-' #Filename:download_file.py import sys,os import urllib.request def urlcallback(a,b,c): """ call back function a,已下载的数据块 b,数据块的大小 c,远程文件的大小 """ prec=100.0*a*b/c if 100 < prec: prec=100 print("%.2f%%"%(prec,)) def main(argv): """ main """ print("start...") urllib.request.urlretrieve("https://bd.phncdn.com/videos/201210/15/6345721/vl_720_831k_6345721.mp4?ipa=47.52.4.119&rs=146&ri=1200&s=1495199710&e=1495206910&h=6a18d80e510cc3deb9f455d39c82931c"\ ,"1.mp4"\ ,urlcallback) print("end...") if __name__=="__main__": main(sys.argv[1:])