'2020/04'에 해당되는 글 1건

  1. 2020.04.24 :: Visual Studio Code에서 Python 코드 작성 및 테스트
IT관련 지식들 2020. 4. 24. 17:11

먼저 Visual Studio Code를 다운받아 설치한다.

 

이후 파이썬을 사용하기 위해서 아래 블로그를 참조했다.

 

https://evols-atirev.tistory.com/31

 

Visual Studio Code Python 사용법

Visual Studio Code 상에서 파이썬 코드를 실행시키고 디버깅하는 방법에 대한 글이다. 우선 파이썬과 Vscode를 설치해준다. Vscode의 설치는 https://evols-atirev.tistory.com/4를 참고해서 설치해준다. Python..

evols-atirev.tistory.com

1. Visual Stdio Code 실행

 

2. open folder선택. 작업을 진행할 폴더를 선택한다.

3. 작업을 진행할 폴더에 새로 파일을 입력한다. (여기서는 helloWorld.py)

- 만약, Visual Studio Code에 Python이 설치되거나 연결되지 않았으면 설치하라는 메시지가 나온다.

- 안내 메시지에 따라 설치하면 된다.

4. 디버깅을 위해 run(F5)를 동작한다.

- launch.json파일을 자동으로 생성해준다.

- 위에 링크된 블로그에서 미리 작성한 코드가 있어 "작업폴더\.vscode"에 task.json과 setting.json 파일을 복사해 넣었다.

4-1. tasks.json

-아래와 같이 작성한다.

{

    // See https://go.microsoft.com/fwlink/?LinkId=733558

    // for the documentation about the tasks.json format

    "version""2.0.0",

    "tasks": [

        {

            "label""python3",

            "type""shell",

            "command":"python",

            "args":["${file}"],

            "group":{

                "kind":"build",

                "isDefault":true

            },

            "presentation":{

                "echo":true,

                "reveal":"always",

                "focus":false,

                "panel":"shared",

                "showReuseMessage":true,

                "clear":true

            }

        }

    ]

}

4-2. setting.json

- 파이썬 실행파일이 설치된 위치를 찾아서 넣어준다.

{

    "python.pythonPath""E:\\Microsoft Visual Studio\\Shared\\Python37_64\\python.exe"

}

 

5. run(F5)를 다시 동작한다.

- Debug Configuration으로 Python File을 선택한다.

- 밑에 콘솔창에서 결과를 볼 수 있다.

posted by 동글동글82
: