加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

expect正则捕获返回结果

发布时间:2020-12-14 02:25:50 所属栏目:百科 来源:网络整理
导读:expect: [plain] view plain copy expect -re "([0-9]*)([a-zA-Z]*)" send_user "num is $expect_out(1,string), string is $expect_out(1,string)" 这里[0-9]*表示一个或多个数字, [a-zA-Z]*表示多个字母。()用于分组,它们分别存放在 $expect_out(1,st

expect:

[plain] view plain copy
  1. expect-re"([0-9]*)([a-zA-Z]*)"
  2. send_user"numis$expect_out(1,string),stringis$expect_out(1,string)"

这里[0-9]*表示一个或多个数字, [a-zA-Z]*表示多个字母。()用于分组,它们分别存放在 $expect_out(1,string)和$expect_out(2,string)中。

pexpect:python中的expect

[plain] view plain copy

    child.expect("([0-9]*)([a-zA-Z]*)
  1. print"numis%s,stringis%s"%(child.match.group(1),child.match.group(2))

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读