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

21번째 줄: 21번째 줄:
quit()
quit()
print('world')
print('world')
root@localhost:~# python3 hello.py
hello
root@localhost:~# echo $!
0
</source>
</source>
<source lang='console'>
<source lang='console'>
root@localhost:~# cat hello1.py
print('hello')
quit(1)
print('world')
root@localhost:~# python3 hello.py  
root@localhost:~# python3 hello.py  
hello
hello
root@localhost:~# echo $!
1
</source>
</source>



2020년 1월 12일 (일) 16:53 판

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 hello1.py 
print('hello')
quit(1)
print('world')
root@localhost:~# python3 hello.py 
hello
root@localhost:~# echo $!
1

3 같이 보기

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