[Python] How to use import sys sys.argv

environment

linux python

python code

The code is as follows as an example.

practice.py


import sys

a = sys.argv

print(a)

command prompt

Execute the following command

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

Then, __ ['practice_home.py','linux','windows','abc'] __ is output as above.

That is, sys.argv contains the characters after __ $ pyton3__ __ </ font> __.

Recommended Posts