를 대화식으로 실행해보며 간단한 실험을 수행하기에 딱 좋습니다. 그러나 긴 작업을 수행해야
한다면, 매번 코드를 입력해야 하는 이 방식은 조금 불편하겠죠. 이럴 때는 파이썬 프로그램을
파일로 저장하고 그 파일을 (함께) 실행하는 방법이 있습니다. 이번 절에서는 그런 파이썬 스
크립트 파일의 예를 살펴보겠습니다.
1.4.1
파일로 저장하기
텍스트 편집기를 열고
hungry
.
py
라는 파일을 작성합니다.
hungry
.
py
는 다음의 한 줄만으로
구성된 파일입니다.
print
("
I
'
m hungry
!")
이어서 터미널을 열고 앞의
hungry
.
py
를 저장한 디렉터리로 이동합니다. 그런 다음 파일 이
름은 “
hungry
.
py
”를 인수로 지정해
python
명령을 실행합니다. 여기에서는
hungry
.
py
가
~/
deep
-
learning
-
from
-
scratch
/
ch01
디렉터리에 있다고 가정합니다.
$
cd
~/
deep
-
learning
-
from
-
scratch
/
ch01
# 디렉터리로 이동
$
python hungry
.
py
I
'
m hungry
!
이처럼
python
hungry
.
py
명령으로 파이썬 프로그램을 실행할 수 있습니다.
1.4.2
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.