Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 |
Tags
- vim
- json
- vscode
- tauri
- yaml
- cli
- secure context
- ndjson
- Java
- uv init
- podman
- io
- UV
- Ollama
- Python Install Manager
- SharedArrayBuffer
- Docker Compose
- Typescript
- cross-origin isolated
- FileChannel
- RandomAccessFile
- json schema
- curl
- Python
- Webpack
- 이미지
- uv pin
- Vite
- docker
- PowerShell
Archives
- Today
- Total
목록import (1)
워로디스
Python sys.path 를 사용해서 특정 경로 파일 임포트
아래처럼 사용자 파일이 있는 폴더 경로를 sys.path에 추가하면, 그 폴더 안의 .py 파일을 일반 모듈처럼 import할 수 있습니다.예시 폴더 구조:my_project/├─ main.py└─ user_files/ └─ my_module.pyuser_files/my_module.pydef hello(name): return f"Hello, {name}!"main.pyimport sysfrom pathlib import Path# 현재 파일(main.py)이 있는 폴더BASE_DIR = Path(__file__).resolve().parent# 사용자가 만든 파이썬 파일들이 있는 폴더USER_FILE_DIR = BASE_DIR / "user_files"# sys.path에 해당 폴더 추가sy..
개발/Python
2026. 5. 3. 22:53
