知識のアウトプットをするブログ

なんでもブログに書き記す

【Python 2.7】Pythonの実行方法2つ

f:id:seisyo58:20181101115332j:plain
Pythonを実行する方法は2つある。

コマンドラインから実行

$ python
>>> print "hello world"
hello world
>>> exit()
$

コマンドラインで実行するには、pythonと実行すればいい。
終了はexit()、もしくはctrl+D

ファイルとして保存して実行

vimで編集

$ vim hello.py

hello.py

print "hello world"

実行

$ python hello.py
hello world
$