0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【公式ドキュメントから学ぶPythonチュートリアル】#1 Pythonインタプリタを使う

Last updated at Posted at 2025-06-11

今回の内容

インタプリタの起動

python3
  • 終了: Ctr + D, quit()
  • ファイルからスクリプトを読み込んで実行: python3 <ファイル名>, python3 < <ファイル名>
  • -iをつけると、スクリプト実行後、そのまま対話モードに入る
  • その他の起動: python3 -c '<command>'<command>を実行する, python3 -m <module><module>を実行する

対話モード

  • 対話モード: インタプリタが命令を端末(tty)やコマンドプロンプトから読み取っているとき。ターミナルから入力しているときもこれに含まれる
  • 一次プロンプト(primary prompt): >>>
  • 二次プロンプト(secondary prompt): ..., 継続行はif文などの複数行の構文を入力するときに使用する
>>> flag = True
>>> if flag:
...    print("Hello, World!")
...
Hello, World!

補足

「引数の受け渡し」「ソースコードの文字コード」について今回は省略させていただきました。理由は、今の時点ではわかりずらいからです(あと、僕がうまく説明できないので。申し訳ない...)
また、今後取り扱う予定です。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?