child = pexpect.spawn ('/bin/bash')
child.sendline('ls')
print(child.readline())
print child.before, child.after
使用这段代码,我在输出中得到的只有
ls
ls
但当我的代码是
child = pexpect.spawn('ls')
print(child.readline())
print child.before, child.after
然后它可以工作,但仅适用于前两次打印。我是否使用了错误的发送命令?我尝试了send、write、sendline,但找不到更多。