0
点赞
收藏
分享

微信扫一扫

【指定浏览器打开文件和指定网址】

晒大太阳了 2022-04-30 阅读 32

指定浏览器打开文件和指定网址

import webbrowser
from pathlib import Path

firefoxPath = r"C:\Program Files\Mozilla Firefox\firefox.exe"
filename = Path("F:\\PDF\\规程(2017版).pdf")

webbrowser.register("firefox", None, webbrowser.BackgroundBrowser(firefoxPath))
webbrowser.get('firefox').open(filename.absolute().as_uri(), new=1, autoraise=True)

# 在默许的浏览器中显现url, 假如new = 0, 那么url会在同一个浏览器窗口下打开,假如new = 1,
# 会打开一个新的窗口,假如new = 2, 会打开一个新的tab, 假如autoraise = True, 窗口会主动增加。

url = "http://10.178.14.160:10040/wps/portal/home/indexhome"
webbrowser.get('firefox').open(url)
举报

相关推荐

0 条评论