LoginSignup
0
1

More than 3 years have passed since last update.

【python】import sys sys.argv の使い方

Posted at

環境

linux
python

pythonコード

コードは例として以下のようにする。

practice.py
import sys

a = sys.argv

print(a)

コマンドプロンプト

以下のコマンドを実行

$ python3 practice_home.py linux windows abc
['practice_home.py', 'linux', 'windows', 'abc']

すると、以上のように['practice_home.py', 'linux', 'windows', 'abc']が出力される。

つまり、sys.argvは $ pyton3後の文字が入る。

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