Python how to read output from pexpect child?

后端 未结 6 1808
攒了一身酷
攒了一身酷 2020-12-29 22:51
child = pexpect.spawn (\'/bin/bash\')
child.sendline(\'ls\')
print(child.readline())
print child.before, child.after

All I get with this code in my

6条回答
  •  我在风中等你
    2020-12-29 23:10

    import sys
    import pexpect
    child = pexpect.spawn('ls')
    child.logfile = sys.stdout
    child.expect(pexpect.EOF)
    

    See the manual entry on the subject.

提交回复
热议问题