Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- proc = subprocess.Popen(
- cmd_line,
- shell=True,
- stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT
- )
- # взаимодействие
- while True:
- proc.stdin.write(b'Y')
- proc.stdin.flush()
- result = proc.stdout.readline()
- print(result.decode('cp866'))
- proc.stdin.write(b'Y')
- # одноразовый ввод, чтение:
- proc.stdin.write(b'y' + b'\n')
- proc.stdin.flush()
- proc.stdin.close()
- result = proc.stdout.read()
- # question, _ = proc.communicate(b'y')
- # print(question.decode('cp866'))
- # см так же тут https://stackoverflow.com/questions/30133357/python-subprocess-popen-stdin-write более низкоуровневое
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement