"파이썬 종료하기 quit()"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(다른 사용자 한 명의 중간 판 6개는 보이지 않습니다)
3번째 줄: 3번째 줄:
;파이썬 quit(), exit()
;파이썬 quit(), exit()


<source lang='python'>
<syntaxhighlight lang='python'>
quit()
quit()
</source>
</syntaxhighlight>
<source lang='python'>
<syntaxhighlight lang='python'>
import sys
import sys
sys.exit(0)
sys.exit(0)
</source>
</syntaxhighlight>
<source lang='python'>
<syntaxhighlight lang='python'>
import os
import os
os._exit(1)
os._exit(1)
</source>
</syntaxhighlight>


==예시==
==예시==
<source lang='console'>
<syntaxhighlight lang='console'>
root@localhost:~# cat hello.py  
root@localhost:~# cat hello.py  
print('hello')
print('hello')
quit()
quit()
print('world')
print('world')
</source>
<source lang='console'>
root@localhost:~# python3 hello.py  
root@localhost:~# python3 hello.py  
hello
hello
</source>
root@localhost:~# echo $?
0
</syntaxhighlight>
<syntaxhighlight lang='console'>
root@localhost:~# cat hello255.py
print('hello')
quit(255)
print('world')
root@localhost:~# python3 hello.py
hello
root@localhost:~# echo $?
255
</syntaxhighlight>


==같이 보기==
==같이 보기==
* [[Python 종료하기]]
* [[종료 코드]]
* [[함수 exit()]]
* [[함수 exit()]]
* [[파이썬 쉘 종료하기]]


[[category:python]]
[[category:python]]
[[분류: Python os]]
[[분류: Python os]]
[[분류: Python sys]]
[[분류: Python sys]]

2020년 11월 2일 (월) 02:32 기준 최신판

1 개요[ | ]

Python quit(), exit()
파이썬 quit(), exit()
quit()
import sys
sys.exit(0)
import os
os._exit(1)

2 예시[ | ]

root@localhost:~# cat hello.py 
print('hello')
quit()
print('world')
root@localhost:~# python3 hello.py 
hello
root@localhost:~# echo $?
0
root@localhost:~# cat hello255.py 
print('hello')
quit(255)
print('world')
root@localhost:~# python3 hello.py 
hello
root@localhost:~# echo $?
255

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}