[英]Python : Opening local html file on browser without using Webbrowser or Selenium
I am using a particular version of Python (v 2.7.0) that doesn't allow me to use webbrowser or selenium libraries.我正在使用不允许我使用 webbrowser 或 selenium 库的特定版本的 Python (v 2.7.0)。
It also doesn't recognise os.startfile.它也不识别 os.startfile。
Is there another module to use that allows me to open up a locally addressed html file in my browser?是否有另一个模块可以让我在浏览器中打开本地寻址的 html 文件?
Since you are using windows you can use os.startfile
which will start a file with its associated application.由于您使用的是 windows,您可以使用
os.startfile
来启动一个文件及其关联的应用程序。
>>> import os
>>> os.startfile("PATH_TO_HTML_FILE")
I fumbled on a result by treating it as an exe and project.我通过将其视为 exe 和项目来摸索结果。 Subprocess module worked.
子流程模块工作。 Tested a little further and should work for Jython 2.7.0 also.
进一步测试,应该也适用于 Jython 2.7.0。
import subprocess as sp
sp.Popen(["browser_exe_path","html_path"])
Note - if using brave browser - it's exe wasn't recognised.注意 - 如果使用勇敢的浏览器 - 它的 exe 无法识别。 chrome_proxy.exe worked in it's place.
chrome_proxy.exe在它的位置工作。
Happy to learn something via feedback.很高兴通过反馈学习一些东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.