Python
- https://www.python.org/
- 1991 Guido Van Rossum
- hacker’s favorite language
basic
| python 실행 | python (py) |
|---|---|
| python 종료 | ctrl + D or exit() |
| python file 실행 | python sample.py, py sample.py |
| python 버전 확인 | python -V, py -V |
pip(legacy)
curl -O https://bootstrap.pypa.io/get-pip.pysudo python get-pip.py
pip commands
pip --helppip listpip install virtualenvpip uninstall virtualenv
uv
- https://github.com/astral-sh/uv
- An extremely fast Python package installer and resolver, written in Rust
- 10-100x faster than pip
- Drop-in replacement for pip, pip-tools, and virtualenv
install
bash# macOS and Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
# With pip
pip install uv
# With brew (macOS)
brew install uv
uv commands
bash# Install packages
uv pip install requests
uv pip install -r requirements.txt
# Create virtual environment
uv venv
uv venv venv # with custom name
# Activate virtual environment
source .venv/bin/activate # macOS/Linux
.venv\Scripts\activate # Windows
# Install packages in virtual environment
uv pip install pandas numpy
# Freeze dependencies
uv pip freeze > requirements.txt
# Uninstall packages
uv pip uninstall requests
# List installed packages
uv pip list
# Sync dependencies (like pip-sync)
uv pip sync requirements.txt
uv features
- Speed: 10-100x faster than pip
- Disk space: Global cache to avoid re-downloading packages
- Reliability: Written in Rust for memory safety
- Compatibility: Drop-in replacement for pip commands
- Resolution: Advanced dependency resolver
virtualenv (legacy)
- closed env
virtualenv venvsource venv/bin/activatedeactivate
python3 (mac)
-
install brew
-
install python3
textbrew install python3
virtualenv -p python3 venv3
source venv3/bin/activate
python -V
deactivate
mac
Python is not installed as a frameworkissue?vi ~/.matplotlib/matplotlibrc
textbackend: TkAgg
파일
- 파일 열어서 한 줄씩 출력하기
- 결과 파일 생성하기
- 참고: https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files
문자열(String)
- 문자열 포함
- 문자열 위치
- 문자열 추출
list(array)
- 배열
scipy on windows
- Unofficial Windows Binaries for Python Extension Packages
ref
- Python Style Guide(PEP8)
- 생활코딩 Python & Ruby
- Tutoiral Point Python
- Python 10 tasks
- jupyter
- jupyter-server
- pyenv
- pandas
- matplotlib
- datetime