pyhton exit
2013-11-01 14:36
176 查看
exit("0") is normally out, and means "successful termination"
exit("1") is abnormal, and means "abnormal termination”. Most systems require it to be in the range 0-127.
sys.exit("some error
message") is a quick way to exit a program when an error occurs.
Since exit() ultimately “only” raises an exception, it will only exit the process when called from the main
thread, and the exception is not intercepted.
import sys, traceback
def main():
try:
do main program stuff here
....
except
KeyboardInterrupt:
print
"Shutdown requested...exiting"
except
Exception:
traceback.print_exc(file=sys.stdout)
sys.exit(0)
if __name__ ==
"__main__":
main()
exit("1") is abnormal, and means "abnormal termination”. Most systems require it to be in the range 0-127.
sys.exit("some error
message") is a quick way to exit a program when an error occurs.
Since exit() ultimately “only” raises an exception, it will only exit the process when called from the main
thread, and the exception is not intercepted.
import sys, traceback
def main():
try:
do main program stuff here
....
except
KeyboardInterrupt:
"Shutdown requested...exiting"
except
Exception:
traceback.print_exc(file=sys.stdout)
sys.exit(0)
if __name__ ==
"__main__":
main()
相关文章推荐
- pyhton exit
- AndroidStudio 导包报 finished with non-zero exit value 2
- clang: error: linker command failed with exit code 1 (use -v to see invocation)
- exit 与 _exit的区别
- SQL语句中in not in exits not exits用法比较
- Export BOM - BOMPXINQ.EXPLODER_USEREXIT API
- with: __enter__ and __exit__
- _exit和exit的区别
- Win7*64+androidstudio ndk-build.cmd finished with non-zero exit value 1 问题原因
- Why Are Thread.stop, Thread.suspend, Thread.resume and Runtime.runFinalizersOnExit Deprecated ?
- "com.android.ide.s.ProcessException:Process 'cand 'C:\Program Files\Java\jdk1.8.0_60\bin\java.exe'' finished with non-zero exit value 2"
- WaitHandle.WaitOne()中的exitContext参数作用
- _exit和exit的区别 http://www.cnblogs.com/hnrainll/archive/2011/08/17/2142001.html
- iOS Xcode错误: linker command failed with exit code 1 (use -v to see invocation) 可能错误与处理方法
- exit(-1)或者return(-1)shell得到的退出码为什么是255
- exit()与_exit()函数的区别(Linux系统中)
- perl中的die|warn|exit
- Android Studio运行工程报错:java.exe'' finished with non-zero exit value 1
- shareSDKb编译报错:clang: error: linker command failed with exit code 1 (use -v to see invocation)
- c语言中exit的简单用法