while 1: try: a = input() print(a) except: break
input에 EOF가 읽히면, EOFError를 발생시키는 것을 이용하여 예외처리로 판단해준다.
출처