The following code works good on unix-base system, and use /tmp
for store file, But how can I use it under windows OS family?
local_filename, headers = urllib.request.urlretrieve('http://127.0.0.1/translations/python-3.7.3.exe')
print(local_filename)
fd = open(local_filename)
fd.close()
From the docs:
Retrieve a URL into a temporary location on disk.
If you don't supply the filename
argument, then urlretrieve()
will call tempfile.NamedTemporaryFile()
to create a file on whatever is the location for temporary files on your operating system. That works under Windows too (the file will be created under %TEMP%
).
If you want a specific location, pass a filename
argument.