哈哈。又到了写博客的时间了。
zio这个模块用了这么久,却一直没时间去看看 源码,真的是很可惜。
源码地址:https://github.com/zTrix/zio/blob/master/zio.py
建议大家去看看。
废话不多说让我们看看这个强大的工具都有哪些方法。
def COLORED(f, color = 'cyan', on_color = None, attrs = None): return lambda s : colored(f(s), color, on_color, attrs)
颜色还是挺常用的
我一般会这么初始化zio
io=zio(target,timeout=10000,print_read=COLORED(RAW,'red'),print_write=COLORED(RAW,'green'))
这些方法大家可以多去了解一下
def RAW(s): return str(s)
来看一下__init__
:
def __init__(self, target, stdin = PIPE, stdout = TTY_RAW, print_read = RAW, print_write = RAW, timeout = 8, cwd = None, env = None, sighup = signal.SIG_DFL, write_delay = 0.05, ignorecase = False, debug = None):
参数相当的多,不过常用的也就没几个
def print_write(self, value):
def print_read(self, value):
def interact(self, escape_character=chr(29), input_filter = None, output_filter = None, raw_rw = True):
def writeline(self, s = ''):
def write(self, s):
def read(self, size = None, timeout = -1):
def read_until_timeout(self, timeout = 0.05):
def read_until(self, pattern_list, timeout = -1, searchwindowsize = None):
def gdb_hint(self, breakpoints = None, relative = None, extras = None):
。。。这篇文章写得有点随意了。
不过还是希望大家多去看看源码,不要嫌烦哦。