2
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Pythonを使ってブラウザを開く

Last updated at Posted at 2019-01-02

webbrowserライブラリのopen関数を使います。

#!/usr/bin/env python3

import webbrowser

webbrowser.open("https://www.google.com") #引数にURLを指定

ブラウザを指定するには下記のようにします。

#!/usr/bin/env python3

import webbrowser

bs = webbrowser.get("/usr/bin/firefox") #ブラウザのパス
bs.open("https://www.google.com")

ちなみに正常に起動できたらTrueを返します。

2
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?