I study python by myself. And i got a problem here.."The human player may also end the game by pressing the Control-D sequence at any time." How can i do this.what kind of function should i use? Thanks.
问问题
8914 次
2 回答
6
You could try sys.exit()
:
import sys
...
sys.exit()
There is also a more standard exit()
function (for which you don't need to import anything). However there is one notable difference between this and sys.exit()
as noted in the documentation:
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.
于 2013-01-01T02:20:15.097 回答