bash pip install pexpect python import pexpect child = pexpect.spawn('bash') child.sendline('ls') child.expect('ls') print(child.before) python import pexpect child = pexpect.spawn('bash') child.sendline('ls -l') child.expect('ls -l') print(child.before) python import pexpect child = pexpect.spawn('bash') child.sendline('ls') child.setTimeout(5) try: child.expect('ls') except pexpect.TIMEOUT: print("Timed out")


上一篇:
下一篇:
切换中文