본문 바로가기
Hadoop

Python에서 표준입력 받는 법(feat. Ubuntu)

by 집못가는프로그래머 2021. 9. 7.

import sys

sys.stdin : 파이썬에서 표준 입력을 받는 방법

예)

import sys

for line in sys.stdin :

   print(line)

output : 표준 입력을 line에 하나하나 받아서 출력을 한다.

 

위와 같은 방법으로

while True :

   str = input()

   if str == '' : 

      break

   print(str)

 

위 두개의 소스코드는 같은 작업을 한다 (표준 입력을 받아 출력)

댓글