This Python script allows users to retrieve current weather conditions and daily forecast information for a specified city using the AccuWeather API.
- City location search
- Current weather conditions retrieval
- Daily forecast information
- Temperature and weather text display
- Supports both Celsius and Fahrenheit measurements
- Python 3.7+
requests
librarypandas
library (optional)- AccuWeather Developer Account and API Key
Install the required Python libraries:
pip install requests pandas
- Create an account at AccuWeather Developer Portal
- Generate an API key
- Replace the
API_KEY
in the script with your personal key
python weather_script.py
- When prompted, enter the name of the city
- The script will display:
- Current temperature
- Current weather conditions
- Minimum and maximum temperatures
- Day and night weather conditions
city_search()
: Finds the location key for a given cityget_current_conditions()
: Retrieves current weather conditionsget_daily_forecast()
: Fetches daily weather forecast
- Checks API response status
- Handles city not found scenarios
- Provides error messages for failed API calls
- Requires active internet connection
- Limited by AccuWeather API request quotas
- Relies on first search result for city matching
- Keep your API key confidential
- Do not commit API keys to version control
- Consider using environment variables for API key storage
- Add support for multiple-day forecasts
- Implement temperature unit conversion
- Create more robust error handling
- Add caching mechanism for API responses
requests
: HTTP library for API callspandas
: Data manipulation (optional)
Contributions, bug reports, and feature requests are welcome!
This project is licensed under MIT License. See the LICENSE file for details.