我是 python 新手,我正在使用此代码下载图像,然后将其保存到与 python 文件相同的目录中。如何将它们保存到另一个文件夹?
def requesthandle( link, name ):
global THREAD_COUNTER
THREAD_COUNTER += 1
try:
r = requests.get( link, stream=True )
if r.status_code == 200:
r.raw.decode_content = True
**Saving images**
f = open( name, "wb" )
shutil.copyfileobj(r.raw, f)
f.close()
print ("[*] Downloaded Image: %s" % name)
except Exception as error:
print ("[~] Error Occured with %s : %s" % (name, error))
THREAD_COUNTER -= 1
DIEA
一只斗牛犬
相关分类