调用蟒蛇webrowser时燮preSS /重定向标准错误 [英] suppress/redirect stderr when calling python webrowser

查看:111
本文介绍了调用蟒蛇webrowser时燮preSS /重定向标准错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有打开的标签页单独的URL几个在新的浏览器窗口中的Python程序,但是当我运行命令行程序,并使用打开浏览器

I have a python program that opens several urls in seperate tabs in a new browser window, however when I run the program from the command line and open the browser using

webbrowser.open_new(url)

从Firefox打印的标准错误打坏。综观文档我似乎无法找到一种方法来重定向或SUP preSS他们

The stderr from firefox prints to bash. Looking at the docs I can't seem to find a way to redirect or suppress them

我已转向使用

browserInstance = subprocess.Popen(['firefox'], stdout=log, stderr=log)

在哪里日志是一个临时文件&安培;然后用webbrowser.open_new打开其他选项卡。

Where log is a tempfile & then opening the other tabs with webbrowser.open_new.

有没有一种方法,将WebBrowser模块内做到这一点?

Is there a way to do this within the webbrowser module?

推荐答案

什么是webbrowser.get()给你?

What is webbrowser.get() giving you?

如果您

 webbrowser.get('firefox').open(url)

那么你不应该看不到任何输出。 WebBrowser控件模块的动产离开STDERR某些浏览器 - 尤其是文本浏览器,然后在那里的人是不特定的。对于已经设置的背景为True所有UnixBrowsers,无输出应该是可见的。

then you shouldn't see any output. The webbrowser module choses to leave stderr for some browsers - in particular the text browsers, and then ones where it isn't certain. For all UnixBrowsers that have set background to True, no output should be visible.

这篇关于调用蟒蛇webrowser时燮preSS /重定向标准错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆