exit()과 sys.exit() 차이를 알고 싶습니다
조회수 32617회
1 답변
-
둘은 비슷한 일을 하지만 쓰는 위치가 다릅니다.
Constants added by the site module에 적혀있길
... They are useful for the interactive interpreter shell and should not be used in programs.
interactive interpreter shell에서 유용하게 쓰이고, 프로그램 안에서는 절대로 쓰면 안 됨
즉,
파일에서
#myfile.py - 파이썬 파일 안에서 import sys exit()#안됨 sys.exit() #됨
쉘에서
$ python Python 2.7.11 (default, Dec 5 2015, 14:44:53) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> exit() #됨 $
댓글 입력