LoginSignup
2
1

More than 5 years have passed since last update.

【初学者向け】Pythonプログラムを作成&実行する方法

Last updated at Posted at 2018-03-03

目的

Pythonプログラムをファイルで保存し実行する。
インストールは【初学者向け】Pythonのインストール方法(GUI Windows)で。

エディタの準備

調べてみると多数ありますが、、

  • IDLE
    Python標準エディタであり本体と同時インストールされる。なんか色々できそう。

IDLEというのを起動すると、スクリプト書いて実行したり、ファイル開いて実行したり、コマンドプロンプトを起動したりできます。
タスクバーにピン止めしておくと便利です。

  • sakuraエディタ
    直観的で軽いのが良い。タイプ別設定でキーワード強調も可。
    お試しには充分か。
  • Visual Studio Code

Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux. It comes with built-in support...

  • Eclipse
    重そう。。
  • Atom
    など

Visual Studio Codeを使っていきたいと思います。
(イマイチ使い方が解っていませんが)

作成→実行方法

  1. 下記内容で、「test1.py」ファイルとして保存します。

    test1.py
    from datetime import datetime  
    dt = datetime.today()  
    print('今日は%s年%s月%s日' % (dt.year, dt.month, dt.day))  
    
  2. VSCodeを使っているので右クリック「ターミナルでPythonファイルを実行」を選択

    結果
    今日は2018年3月3日
    

拡張子を「py」とすることでPythonのPGと見做されます。

2
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
2
1