Berlin 1


# coding: utf-8
import requests

params = {
  'access_key': 'YOUR_ACCESS_KEY',
  'query': 'Berlin'

api_result = requests.get('', params)

api_response = api_result.json()

print(u'Current temperature in %s is %d℃' % (api_response['location']['name'], api_response['current']['temperature']))

Here is what the above code is Doing:
1. We’re using the requests library to make a GET request to the API.
2. We’re passing the API key and the query as parameters to the request.
3. We’re converting the response to a Python dictionary using the json() method.
4. We’re printing the current temperature in Berlin.

Similar Posts