2024-04-24 20:19:53 发布
网友
请帮助我从功能的不同方面澄清这两个python语句的概念:
sys.exit(0)
os._exit(0)
os._exit调用C函数_exit(),该函数执行即时程序 终止。请注意“永远不能返回”这句话。
os._exit
_exit()
sys.exit()与raise SystemExit()相同。它养了一条Python 调用方可能捕获的异常。
sys.exit()
raise SystemExit()
原帖:http://bytes.com/topic/python/answers/156121-os-_exit-vs-sys-exit
根据documentation:
os._exit(): Exit the process with status n, without calling cleanup handlers, flushing stdio buffers, etc.Note The standard way to exit is sys.exit(n). _exit() should normally only be used in the child process after a fork().
os._exit():
Exit the process with status n, without calling cleanup handlers, flushing stdio buffers, etc.
Note The standard way to exit is sys.exit(n). _exit() should normally only be used in the child process after a fork().
sys.exit(n)
fork()
os._exit
调用C函数_exit()
,该函数执行即时程序 终止。请注意“永远不能返回”这句话。sys.exit()
与raise SystemExit()
相同。它养了一条Python 调用方可能捕获的异常。原帖:http://bytes.com/topic/python/answers/156121-os-_exit-vs-sys-exit
根据documentation:
相关问题 更多 >
编程相关推荐