sys.argvを使う。
(サンプルプログラム)
import sys arg1 = sys.argv # コマンドライン引数がリストで返る。 print(arg1)
(実行結果)
$ python3 hello.py This is a pen. ['hello.py', 'This', 'is', 'a', 'pen.']
sys.argvを使う。
(サンプルプログラム)
import sys arg1 = sys.argv # コマンドライン引数がリストで返る。 print(arg1)
(実行結果)
$ python3 hello.py This is a pen. ['hello.py', 'This', 'is', 'a', 'pen.']