the following "example.exe" C++ program:
int main(int argc, char *argv[]) { int number = 0; do { scanf("%d", &number); for(int x=1; x<=number; x++) { printf("%d n", x); } } while (number >= 1); return EXIT_SUCCESS; }
Code:
import subprocess, os PIPE = subprocess.PIPE p = subprocess.Popen("example.exe", stdin=PIPE, stdout=PIPE) p.stdin.write("10") p.stdin.flush() print p.stdout.read() #Deadlock print "End of Execution" os.system("PAUSE")
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
» | 외부 프로그램 실행 | pjk | 2015.02.10 | 15365 |
7 | Python으로 작성된 프로그램을 윈도우응용프로그램(exe)으로 빌드하기 | pjk | 2014.08.03 | 8095 |
6 | Python 문자열 관련 함수 레퍼런스 | pjk | 2014.08.29 | 6786 |
5 | print를 로그파일로 생성하기 (log출력 Redirection) | makersweb | 2015.03.18 | 5697 |
4 | 다른 디렉터리의 파일(모듈) import 하기 | pjk | 2014.08.22 | 4697 |
3 | 명령어 한줄로 내컴퓨터를 웹서버로 | 운영자 | 2019.01.25 | 3546 |
2 | 우분투에 Python새 버전 설치 사용법 | pjk | 2015.02.10 | 3246 |
1 | pybind11 에 대해서 | makersweb | 2023.07.23 | 2065 |