def attempt_open(url):
import os
import webbrowser
if 'DISPLAY' not in os.environ:
print('The DISPLAY variable is not set, so not attempting to open a web browser\n')
return False
for name in 'windows-default chrome chromium mozilla firefox opera safari'.split():
# LATER: prepend `macosx` to this list when <http://bugs.python.org/issue30392> is fixed.
try:
b = webbrowser.get(name)
except:
pass
else:
if b.open(url):
return True
return False
评论列表
文章目录