C++로 컴파일해서 만든 실행파일을 python에서 쓰고 싶었는데, 방법을 몰라 고민하던 차에 나름의 방법을 알아냈다.
import os
import sys
os.system('./hello_world')
이러면 hello_world 가 실행됨. (출력물 : hello world!)
여기서 나온 결과값을 저장하려면 subprocess를 쓰면 됨.
import subprocess
result = subprocess.check_output('./hello_world', shell=True)
print (result)
이러면 result에 hello world!가 잘 저장되어있다.
와 파이썬 진짜 좋다.....ㅎ...
'Computer > Python' 카테고리의 다른 글
[Python] Windows에 jupyter notebook 설치하기 [feat. 머신러닝] (0) | 2020.11.19 |
---|---|
[Python] 파일 읽어올때 자료형 변환하기 (0) | 2019.09.10 |
[Python] python으로 .py 돌리기 (0) | 2019.09.10 |
[Python] 디렉토리의 파일 접두사 삭제 (0) | 2019.09.09 |