首页IT科技python3 except用法(python中Pexpect的工作流程)

python3 except用法(python中Pexpect的工作流程)

时间2025-06-20 23:55:22分类IT科技浏览3430
导读:本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。...

本文教程操作环境:windows7系统            、Python 3.9.1           ,DELL G3电脑            。

1                 、工作流程步骤

(1)用spawn来执行一个程序;

(2)用expect方法来等待指定的关键字                  ,这个关键字是被执行的程序打印到标准输出上面的;

(3)当发现这个关键字以后      ,使用send/sendline方法发送字符串给这个程序                 。

2      、实例

spawn类

classspawn(SpawnBase): ThisisthemainclassinterfaceforPexpect.Usethisclasstostart andcontrolchildapplications. #Thisispurelyinformationalnow-changingithasnoeffect use_native_pty_fork=use_native_pty_fork def__init__(self,command,args=[],timeout=30,maxread=2000, searchwindowsize=None,logfile=None,cwd=None,env=None, ignore_sighup=False,echo=True,preexec_fn=None, encoding=None,codec_errors=strict,dimensions=None, use_poll=False):

通过spawn()方法用来执行一个程序        ,返回程序的操作句柄                  ,后续就可以通过操作句柄来与这个程序进行交互了      。

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
php手机验证码验证(phpcms怎么调用验证码)