Python 3.x 在google中从windows打开文件或在python中从internet浏览文件
strong text我想在不同平台的web浏览器中打开该文件,我在#Mac和#linux上打开过,但我的问题是我不知道在windows上。 这是我的代码:Python 3.x 在google中从windows打开文件或在python中从internet浏览文件,python-3.x,Python 3.x,strong text我想在不同平台的web浏览器中打开该文件,我在#Mac和#linux上打开过,但我的问题是我不知道在windows上。 这是我的代码: f = open(orginal_filename, "r") if os.name == "darwin": #Mac sp.Popen(["open", orginal_filename]) elif os.name=='posix': #linux sp.Popen(["firefox", orgina
f = open(orginal_filename, "r")
if os.name == "darwin": #Mac
sp.Popen(["open", orginal_filename])
elif os.name=='posix': #linux
sp.Popen(["firefox", orginal_filename])
elif os.name=="nt": #win
sp.Popen(["?????", orginal_filename])
在windows中签出此问题它不工作,因为包含可执行文件的文件夹不在您的
PATH
变量中。它没有解决我的问题,它只是根据以下代码打开我代码的当前文件夹:import subprocess subprocess.Popen(r'explorer/select,“C:\PATH\of\folder\file”)