Saving files downloaded from Urlretrieve to another folder other [closed]

StackOverflow https://stackoverflow.com/questions/20338452

  •  07-08-2022
  •  | 
  •  

سؤال

Currently have this working and its downloading the files correctly but is placing them in the same folder where it is being ran from, but how would i go about say moving these to c:\downloads or something like this?

urllib.urlretrieve(url, filename)
هل كانت مفيدة؟

المحلول

filename is basically your reference to the file and where it is stored. Using the following command

fullfilename = os.path.join(myPath, filename)
urllib.urlretrieve(url, fullfilename)

You should be able to store it at myPath.

Don't forget to place

import os

at the top of your script..

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top