发布时间:2019-09-15 10:01:33编辑:auto阅读(1971)
#!/bin/python #coding:utf-8 def wget(url,new_name=""): ''' wget封装,需提供下载地址,新文件名参数可省略 ''' try: file_name = url[url.rfind("/")+1:] if new_name == "": new_name = file_name fp = urllib.urlopen(url) py_ver = sys.version[:3] if fp.getcode() != 200: raise NameError,'%s not exist.'%file_name buf_len = 2048 f = open(new_name,'wb') size = 0 while 1: s = fp.read(buf_len) if not s: break f.write(s) size += len(s) fp.close() f.flose() print "%s success"%url except Exception,e: print Exception,":",e
上一篇: python 多线程处理List
下一篇: python之cmd库学习
47610
45997
36913
34477
29088
25727
24573
19718
19253
17761
5571°
6161°
5695°
5749°
6712°
5487°
5492°
5994°
5968°
7300°