相关疑难解决方法(0)

Python中的"哪个"等效函数

我需要通过运行which abc命令来设置环境.是否有Python等效的which命令功能?这是我的代码.

cmd = ["which","abc"]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
res = p.stdout.readlines()
if len(res) == 0: return False
return True
Run Code Online (Sandbox Code Playgroud)

python command which

64
推荐指数
4
解决办法
4万
查看次数

如何使用 Web 浏览器从 Python 脚本启动 Microsoft Edge

使用webbrowser lib,我可以从 python 脚本启动 Chrome 和 Firefox。Edge 则失败了。我注意到使用webdriver启动 Edge 的方法,但我的问题是是否可以使用以下脚本来启动 Edge。目前它仅启动 Chrome。

import webbrowser

chrome_path="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
edge_path="C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe"

webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(chrome_path))
webbrowser.register('edge', None, webbrowser.BackgroundBrowser(edge_path))

webbrowser.get('chrome').open('http://www.google.com')
webbrowser.get('edge').open('http://www.microsoft.com')
Run Code Online (Sandbox Code Playgroud)

python python-webbrowser

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

python ×2

command ×1

python-webbrowser ×1

which ×1