From b238eb6633ff98348420a6ca61f5c32436e3b519 Mon Sep 17 00:00:00 2001 From: BeomJoon Park Date: Thu, 27 Jun 2024 02:39:23 +0000 Subject: [PATCH] modify prac4.py --- __pycache__/prac1.cpython-311.pyc | Bin 415 -> 415 bytes __pycache__/prac2.cpython-311.pyc | Bin 724 -> 724 bytes __pycache__/prac3.cpython-311.pyc | Bin 646 -> 646 bytes "prac4_\353\260\225\353\262\224\354\244\200.py" | 16 ++++++++++++++++ 4 files changed, 16 insertions(+) create mode 100644 "prac4_\353\260\225\353\262\224\354\244\200.py" diff --git a/__pycache__/prac1.cpython-311.pyc b/__pycache__/prac1.cpython-311.pyc index 0dd9d222a7070054dca615daa15702619d02f868..082d71219926c3317612fa2c2ceb97f448507c50 100644 GIT binary patch delta 20 acmbQwJfE3+IWI340}w1ZUbB&V3L^kC3I$UD delta 20 acmbQwJfE3+IWI340}$|5i*Mwf!UzB?C1H}LU diff --git "a/prac4_\353\260\225\353\262\224\354\244\200.py" "b/prac4_\353\260\225\353\262\224\354\244\200.py" new file mode 100644 index 0000000..2b942db --- /dev/null +++ "b/prac4_\353\260\225\353\262\224\354\244\200.py" @@ -0,0 +1,16 @@ +# prac4.py + +def read_file(): + ''' + file_name을 입력받고, file_name에 해당하는 파일이 있다면, 해당 파일에 내용을 출력하는 코드를 작성하여라. + 단, 만약 파일이 존재하지 않는 경우에는 해당 에러를 예외처리하는 코드를 작성하여라. + ''' + file_name = input() + try: + with open(file_name, 'r') as f: + data = f.read() + except FileNotFoundError: + print('There is no file has that file name') + +if __name__ == "__main__": + read_file() \ No newline at end of file