Skip to content
Advertisement

Alternative of urllib.urlretrieve in Python 3.5

I am currently doing a course on machine learning in UDACITY . In there they have written some code in python 2.7 but as i am currently using python 3.5 , i am getting some error . This is the code

JavaScript

I tried urllib.request .

JavaScript

But still gives me error .

JavaScript

I am using PyCharm as my IDE .

Advertisement

Answer

You’d use urllib.request.urlretrieve. Note that this function “may become deprecated at some point in the future”, so you might be better off using the less likely to be deprecated interface:

JavaScript

For small enough files, you could just read and write the whole thing and drop the loop entirely.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement