카테고리 없음
Yml
유키공
2025. 4. 23. 10:21
import yaml
# YAML 파일 로드
with open('config.yml') as f:
config = yaml.safe_load(f)
# 값 접근
print(config['app']['name']) # "My Awesome App"
print(config['database']['production']['credentials']['username']) # "admin"
# 리스트 항목 접근
for feature in config['app']['features']:
print(feature)
app:
name: "My Awesome App"
version: 2.3.1
features:
- "authentication"
- "data_export"
- "notifications"
settings:
cache_enabled: true
max_retries: 3
allowed_file_types: [".jpg", ".png", ".pdf"]