커뮤니티

  Python   view

  vs code 계층적 모듈 참조2020-12-10 11:05/김윤중/1291

vs code 모듈 참조

  • 방법1
    • ​import sys
      from pathlib import Path
      sys.path[0] = str(Path(sys.path[0]).parent)
    • folder 구조
      • yolov3
        • utils.py
      • tools
        • a.py 의 내용
          from pathlib import Path
          sys.path[0] = str(Path(sys.path[0]).parent)
          from yolov3.utils imprt Print
          Print('log.txt')
          Print('message')
  • 방법2
    • launch.json 설정
    • {
          // Use IntelliSense to learn about possible attributes.
          // Hover to view descriptions of existing attributes.
          // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
          "version": "0.2.0",
          "configurations": [
              {
                  "name": "Python: Current File (integrated)",
                  "type": "python",
                  "request": "launch",
                  "program": "${file}",
                  "console": "integratedTerminal",
                  "cwd": "${workspaceFolder}",
                  "env": {
                      "PYTHONPATH": "${workspaceRoot}"
                  }
                 
              }
          ]
      }

re m d      LIST