728x90
import sys

args = sys.argv[1:]
for arg in args:
    print(i)

 

터미널(명령 프롬프트)에서 파이썬 파일을 실행할 때, 인자를 입력해 주면 다음과 같이 나타난다.

>> python newfile.py a b c d

a
b
c
d

 

인자를 대문자로 바꿔주기

import sys

args = sys.argv[1:]
for arg in args:
    print(i.upper(), end=' ')

 

>> python newfile2.py hello, world

HELLO, WORLD
728x90

+ Recent posts