[Tutor] use of webbrowser.open_new()

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Mon Aug 8 07:26:33 CEST 2005



On Sun, 7 Aug 2005, Tom Cloyd wrote:

> Having just discovered the webbrowser module, I've confirmed that I can
> indeed open a URL in my default browser using something like
>
> webbrowser.get_new("{URL}")
>
> What I want to do is open a web page stored on my local machine. I'm not
> getting it to work -
>
> webbrowser.open_new("C:\__Library\folders\05238 Design for Confusion\05238
> Design for Confusion -05krugman.html")

Hi Tom,

Not sure if this is relevant, but Local file urls should have a "file:///"
prefix.  For the specific details Section 3.10 of:

    http://www.faqs.org/rfcs/rfc1738.html

shows the syntax of file URLs.

You may want to double check that the file that you're trying to open does
exist: it has an unusual file name, and even small typos will cause
issues.  Try using webrowser.open_new on simpler file names first, to see
if those work out for you.


Good luck!



More information about the Tutor mailing list