[Tutor] Selecting a browser

Kent Johnson kent37 at tds.net
Tue Dec 4 02:05:35 CET 2007


Ricardo Aráoz wrote:
>>>> import webbrowser
>>>> ff = webbrowser.get("S:\FirefoxPortable\FirefoxPortable.exe %s &")
>>>> ff.open('http://www.google.com')
> False

Beware of backslashes in file paths - backslash introduces a character 
escape in Python strings. You can fix by any of
- use \\ instead of \
- use / instead of \ (it works fine)
- use raw strings (prefix with r) e.g. 
r"S:\FirefoxPortable\FirefoxPortable.exe %s &"

Kent


More information about the Tutor mailing list