저번에는 파이썬으로 echo 명령어로 출력만 해봤는데요 이번에는 .py 확장자를 가진 파이썬 파일을 실행시켜 볼 것 입니다!

 

일단 저는 vsc (비쥬얼 스튜디오 코드)에서 파이썬 파일을 생성하고 코딩해봤습니다. 다른 편집기를 사용하시는 분들은 같은 방식으로 해도 상관은 없을 것 같아요 파이썬은 아톰을 많이 사용하시더라구요 

 

code.visualstudio.com/

 

Visual Studio Code - Code Editing. Redefined

Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.  Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.

code.visualstudio.com

 

 

 

atom.io/

 

A hackable text editor for the 21st Century

At GitHub, we’re building the text editor we’ve always wanted: hackable to the core, but approachable on the first day without ever touching a config file. We can’t wait to see what you build with it.

atom.io

 

TMI 이지만 저는 js를 사용할 때 vsc를 많이써서 익숙해져있어서 vsc를 사용했습니다.

 

이전 포스팅에서 파이썬을 설치했다는 가정하에 vsc에 들어가  제일 상단 왼쪽에있는 File을 누른뒤  New File을 해줍니다.

그리고 test.py라고 이름을 변경후 오른쪽 아래 빨간 네모박스처럼 MagicPython으로 변경을 해줍니다. 

그리고 경로를 잡아줍니다. 저는 D드라이브에 test.py 라는 파일을 생성하고 

print("Hello, world!")

print("헬로우 월드!")

라는 코드를 입력해줬습니다.

print("Hello, world!")
print("헬로우 월드!")

이렇게 완료가 되었으면 

vsc 나 다른 편집 툴을 사용하신다면 터미널을 여시거나 cmd, 윈도우 쉘 등 커멘드 라인에 들어가

내가 생성한 경로에서 python 내가 만든 파이썬파일이름.py  명령어를 입력해줍니다. 그러면 아래처럼 결과가 나옵니다.

 

파일을 만들어 실행시켜 보기를 해봤습니다. 감사합니다 :) 

'python' 카테고리의 다른 글

python 설치하기  (0) 2020.12.09

+ Recent posts