Python のプログラムを quit() メソッドで終了させる Python プログラムを exit() メソッドで終了する sys.exit() メソッドで Python プログラムを終了する Python プログラムを os.exit() メソッドで終了させる 終了コード PHP と同様に、die() コマンドは実行中のスクリプトを終了させます。同様に、quit()、exit()、sys.exit()、os.exit() などの組み込み関数を用いて Python スクリプトを終了させることができます。Python は命令を上から順に実行し、基準に従ってコードに定義されたループを実行しますが、Python インタプリタはファイル EOF の最後に到達すると、それ以上の命令を読み込めなくなるため、実行を終了します。 この記事では、Python でプログラムを終了させる方法を紹介します。