Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'startup': 0.05; 'subject:file': 0.07; 'filename': 0.09; 'function,': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'language.': 0.14; '24,': 0.16; 'advanced,': 0.16; 'bottom;': 0.16; 'chrome,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'language': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'trying': 0.19; 'settings': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'looks': 0.24; 'supported': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'leave': 0.29; 'default,': 0.31; 'sep': 0.31; 'file': 0.32; 'themselves': 0.32; 'open': 0.33; 'url:python': 0.33; 'subject:the': 0.34; 'subject:with': 0.35; "i'll": 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'changing': 0.37; 'operating': 0.37; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'subject:can': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'url:3': 0.61; 'save': 0.62; 'offer': 0.62; 'making': 0.63; 'our': 0.64; 'charset:windows-1252': 0.65; 'panel': 0.68; 'skip:w 30': 0.69; 'default': 0.69; 'browser.': 0.78; 'exercise.': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: why can't open the file with browser? Date: Wed, 24 Sep 2014 17:41:49 +0100 References: <54228F92.90409@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host-92-22-89-125.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1411576932 news.xs4all.nl 2952 [2001:888:2000:d::a6]:44429 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78298 On 24/09/2014 13:22, Chris Angelico wrote: > On Wed, Sep 24, 2014 at 7:32 PM, luofeiyu wrote: >> import webbrowser webbrowser.open('f:\\test.html') why the file >> f:\\test.html is opened by notepad ,not by my firefox or chrome? > > It looks to me as if your default association is set to Notepad rather > than a web browser. Try opening one of the browsers' settings pages > and making it your default browser. In Chrome, that's > chrome://settings/ and it's near the bottom; in Firefox, go to > Tools|Options, Advanced, and it's on the General tab. (They might > check on startup and offer to make themselves default, which would > save you some trouble.) > > ChrisA > From https://docs.python.org/3/library/webbrowser.html#module-webbrowser "Note that on some platforms, trying to open a filename using this function, may work and start the operating system’s associated program. However, this is neither supported nor portable." So it looks like a case of changing the file association through control panel or similar. I'll leave the OP to find out how to do that as an exercise. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence