You gotta love a 2-line python solution

Terry Reedy tjreedy at udel.edu
Mon May 2 02:46:27 EDT 2016


On 5/2/2016 12:31 AM, Stephen Hansen wrote:
> On Sun, May 1, 2016, at 08:39 PM, DFS wrote:
>> To save a webpage to a file:
>> -------------------------------------
>> 1. import urllib
>> 2. urllib.urlretrieve("http://econpy.pythonanywhere.com
>>      /ex/001.html","D:\file.html")
>> -------------------------------------
>
> Note, for paths on windows you really want to use a rawstring. Ie,
> r"D:\file.html".

Or use forward slashes "D:/file.html" and avoid the issue.  I don't know 
of anywhere this does not work for file names sent from python directly 
to Windows.

-- 
Terry Jan Reedy




More information about the Python-list mailing list