弃用 是一回事, 将来可能在某个时候弃用 是另一回事。
如果适合您的需求,我会继续使用
urlretrieve。
也就是说,您可以不用它:
from urllib.request import urlopenfrom shutil import copyfileobjwith urlopen(my_url) as in_stream, open('my_filename', 'wb') as out_file: copyfileobj(in_stream, out_file)
弃用 是一回事, 将来可能在某个时候弃用 是另一回事。
如果适合您的需求,我会继续使用
urlretrieve。
也就是说,您可以不用它:
from urllib.request import urlopenfrom shutil import copyfileobjwith urlopen(my_url) as in_stream, open('my_filename', 'wb') as out_file: copyfileobj(in_stream, out_file)