본문 바로가기

Computer/Python

[Python] python으로 .py 돌리기

- 0. 참고 사이트

Python 3.5.3 (default, May 14 2019, 20:22:05) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> filename = "tmp.py"
>>> exec(open(filename).read())

해서 돌리면 tmp.py안에 선언했던 변수들을 모두 그대로 사용할 수 있다.

여러개의 파일을 실행하고 싶을 때는 위의 참고사이트를 확인해 볼 것.(혹은 향후 추가)