# 날씨 API 호출 weather_url = "https://api.openweathermap.org/data/2.5/weather" params = { "q": location_eng, "appid": weather_api_key, "units": "metric", # 섭씨 온도 "lang": "kr" } weather_response = requests.get(weather_url, params=params) weather_data = weather_response.json() # 실패 시 처리 if "main" not in weather_data: print("날씨 정보를 가져오는 데 실패했습니다.") print("오류 메시지:", weather_data.get("message", "알 수 없는 오류")) print("전체 응답:", weather_data) exit() # 결과 구성 weather_result = { "location": location_eng, "temperature": weather_data["main"]["temp"], "condition": weather_data["weather"][0]["description"] }