MapleStory Finger Point

๐Ÿƒ‍โ™‚๏ธBaekjoon/Python

#11718 - python

HYEJU01 2024. 4. 16. 18:57
while True:
    try:
        print(input())
    except EOFError:
        break

์–ผ๋งˆ๋‚˜ ์ž…๋ ฅ๋ฐ›์„์ง€ ์กฐ๊ฑด์ด ๋‚˜์™€์žˆ์ง€ ์•Š๋‹ค.

๊ทธ๋ž˜์„œ while ๋ฌธ์œผ๋กœ ์ž…๋ ฅ์„ ๊ณ„์†ํ•ด์„œ ๋ฐ›๋ฐ

์–ด์จŒ๋“  while ๋ฌธ์ด ๋๋‚˜๋ ค๋ฉด  ๊ทธ ๋์„ ์•Œ์•„์•ผํ•จ

์ฆ‰ => EOF (End of File) ๋ฅผ ์•Œ๋ฉด ๋จ.

EOF์—๋Ÿฌ๋ฅผ ์ฒ˜๋ฆฌํ•ด์ฃผ๋ฉด ๋จ.

 

 

๐Ÿ’ฌ "EOF ์—๋Ÿฌ(End of File ์—๋Ÿฌ)" :  ํ”„๋กœ๊ทธ๋žจ์ด ํŒŒ์ผ์˜ ๋์„ ๋งŒ๋‚˜์ง€ ๋ชปํ•˜์—ฌ ๋ฐœ์ƒํ•˜๋Š” ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค.

๐Ÿ’ฌ 1) try-except ๋ฌธ ์‚ฌ์šฉ . EOFError ์˜ˆ์™ธ ์žก์•„์ฃผ๊ธฐ

๐Ÿ’ฌ 2) ํŒŒ์ผ ์ฝ์„ ๋•Œ EOF ์—๋Ÿฌ ์žก๊ธฐ : ํŒŒ์ผ์„ ์ฝ์„ ๋•Œ EOF ์—๋Ÿฌ๋ฅผ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด readline() ๋˜๋Š” readlines() ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  EOF ์—๋Ÿฌ๋ฅผ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.