我在Windows上运行Python3.3.5,我正在处理的一个非常基本的版本如下所示:import os
import subprocess
import time
path = r"C:\Users\Luke\Desktop\Tor_Browser\Browser\firefox.exe {0}"
url = "http://google.com"
views = 5
opened = 0
for i in range(views):
subprocess.Popen(path.format(url))
time.sleep(15)
opened = opened + 1
print ("Times opened:", opened)
os.system("taskkill /f /im firefox.exe")
这段代码应该做的是用googleurl运行我的firefox/tor浏览器5次,每次15秒,然后关闭它。
它只是这样做的,然而,我似乎无法阻止终端显示文本:“成功:过程”火狐.exe“PID xxxx已终止。”
我试着换线了
^{pr2}$
到FNULL = open(os.devnull, 'w')
subprocess.Popen("taskkill /f /im firefox.exe", stdout=FNULL)
但当我这样做时,程序只打开一次浏览器,关闭它,然后停止打开它,但仍然显示“打开次数”文本。在
有人知道如何阻止终端显示这段文字吗?在
谢谢
-卢克