我需要通过运行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) 使用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)