用于捕获sys.stdout和-err的库

stdget的Python项目详细描述


StdGet

StdGet is a small python 2 and 3 compatible library that doesn't require any modules to work.

What does it do?

StdGet's purpose is to be a way to capture the StdOut (Standard Output) and StdErr (Standard Error Output).

Sounds great! How does it work and how do I use it?

How to use it:

First, let's import StdGet: import stdget Then, let's say we want to capture the StdOut: stdget.startstdoutcapture() And you're done! "But how do I get the information it captures?" stdget.stdouthook will give you a list. You can just do stdget.stdouthook=[] to empty it.

How it works:

What it does is it adds a layer on top of the original 'sys.stdout.write' that actually 'takes' the data and copies it into the 'stdget.stdouthook' list. It works outside of the module's layer because the sys.stdout / -in and -err are global all across the session. That's also why you can just do import stdget and you don't have to do from stdget import * (it doesn't matter).

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在Android Studio中使用while循环显示包含textview对象的数据   创建名为“userController”的bean时发生java错误:通过字段“userService”表示未满足的依赖关系   java PDFBox PDFImageWrite。writeImage未正确处理所有字符   java无法识别代码中的nzec错误   无法更改java TabLayout字体   在Java中使用子字符串删除部分字符串   Java中的listener addPropertyChangeListener方法   java可以同时拖动多个对象   java如何将数组中的值添加到向量中   java为什么在Camel 3.7.3中无法正确计算属性?   与后端问题不同的机器中的java客户端资源   带字符串的java分割字节数组?   java On_选项_项目_选择的方法说明   java如何在画布的父画中画一个圆?   连接超时和打开连接数的java Netty通道配置   java mysql中如何防止向数据库中插入重复数据   升级到macOS Big Sur后,java无法启动Neo4j控制台应用程序   在Java中使用XSLT将XML转换为HTMLString的ajax   java无法使用Apache POI获取Excel工作表中的数据