一、说明
urllib提供了一系列用于操作URL的功能
二、代码
from urllib import request
import os,sys
def donwloadFile(url):
dir = os.getcwd()
print(dir)
if not os.path.exists('filedownload'):
os.mkdir('filedownload')
os.chdir(dir+'/filedownload')
filename = url.split('/')[-1]
reponse = request.urlopen(url)
content = reponse.read()
with open(filename,'wb') as fw:
fw.write(content)