Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.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
在RPi2上的Python脚本的Epiphany中打开URL_Python_Terminal_Midori - Fatal编程技术网

在RPi2上的Python脚本的Epiphany中打开URL

在RPi2上的Python脚本的Epiphany中打开URL,python,terminal,midori,Python,Terminal,Midori,所以我试图在Epiphany WebBrowser中打开一个URL[比如说http://www.google.com]来自python脚本。我的python脚本如下所示: import os string = "DISPLAY=:0 xdg-open http://www.google.com" os.system(string) #google.sh DISPLAY=:0 xdg-open http://www.google.com # test.py import os str

所以我试图在Epiphany WebBrowser中打开一个URL[比如说
http://www.google.com
]来自python脚本。我的python脚本如下所示:

import os
string = "DISPLAY=:0 xdg-open http://www.google.com"
os.system(string)
#google.sh    
DISPLAY=:0 xdg-open http://www.google.com
# test.py
import os

string = "/home/pi/google.sh"
os.system(string)
它返回错误:
xdg open:没有可用于打开的方法'http://www.google.com“

但是,如果我键入
DISPLAY=:0 xdg openhttp://www.google.com
进入LX终端工作正常。它还可以通过SSH远程工作

有什么想法吗?还有人能给我解释一下为什么命令在终端中运行良好,但在您尝试使用
os.system()
从Python脚本调用命令时却不行吗

更新--仍然需要帮助

注意:所有文件都位于
/home/pi

在经历了很多挫折之后,我想我应该尝试一下下面的方法。我创建了一个名为
google.sh
的文件。
google.sh
s的代码如下:

import os
string = "DISPLAY=:0 xdg-open http://www.google.com"
os.system(string)
#google.sh    
DISPLAY=:0 xdg-open http://www.google.com
# test.py
import os

string = "/home/pi/google.sh"
os.system(string)
当我从LXTerminal使用
/google.sh
调用这个程序时,它工作得很好Great现在让我们从名为
test.py的python脚本调用它,其代码如下:

import os
string = "DISPLAY=:0 xdg-open http://www.google.com"
os.system(string)
#google.sh    
DISPLAY=:0 xdg-open http://www.google.com
# test.py
import os

string = "/home/pi/google.sh"
os.system(string)
但是由于某些原因,它仍然返回:
xdg open:no method available for open'http://www.google.com“

这个怎么样? 这个想法是打开一个顿悟窗口,5秒钟后关闭它

import subprocess
from time import sleep

p = subprocess.Popen("exec epiphany-browser http://yahoo.com", stdout=subprocess.PIPE,shell=True)
sleep(5)
p.kill()
print("done")