You gotta love a 2-line python solution

DFS nospam at dfs.com
Mon May 2 21:12:13 EDT 2016


On 5/2/2016 8:45 PM, jfong at ms4.hinet.net wrote:
> DFS at 2016/5/2 UTC+8 11:39:33AM wrote:
>> To save a webpage to a file:
>> -------------------------------------
>> 1. import urllib
>> 2. urllib.urlretrieve("http://econpy.pythonanywhere.com
>>      /ex/001.html","D:\file.html")
>> -------------------------------------
>>
>> That's it!
>
> Why my system can't do it?
>
> Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (In
> tel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from urllib import urlretrieve
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ImportError: cannot import name 'urlretrieve'


try

from urllib.request import urlretrieve

http://stackoverflow.com/questions/21171718/urllib-urlretrieve-file-python-3-3


I'm running python 2.7.11 (32-bit)



More information about the Python-list mailing list