>>> import sys
>>> print sys.exit.__doc__
exit([status])
Exit the interpreter by raising SystemExit(status).
If the status is omitted or None, it defaults to zero (i.e., success).
If the status is numeric, it will be used as the system exit status.
If it is another kind of object, it will be printed and the system
exit status will be one (i.e., failure).
所以,基本上,你会这样做:
from sys import exit
# Code!
exit(0) # Successful exit
sys.exit()会做你想做的事。
你可以
raise SystemExit(0)
而不是去import sys; sys.exit(0)
麻烦。你想要
sys.exit()
。来自Python的文档:所以,基本上,你会这样做:
相关问题 更多 >
编程相关推荐