Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 在google中从windows打开文件或在python中从internet浏览文件_Python 3.x - Fatal编程技术网

Python 3.x 在google中从windows打开文件或在python中从internet浏览文件

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

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", 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”)