Combine API Calls, Trouble with other categories besides 'Current Conditions' (in Python)

  • 1
  • Question
  • Updated 6 years ago
Hi All:

when writing my code for something like current latitude:
import urllib2
import json
json_string =
parsed_json = json.loads(json_string)
location1 = parsed_json ['location']['lat']

I am given the latitude, however when attempting the same with categories such as forecast, tide or astronomy:
sunrise = parsed_json ['sunrise']
print "\nSunrise at: %s" % (sunrise)

I get errors saying sunrise is out of this a wunderground issue or a python issue?
Photo of phluffhed


  • 3 Posts
  • 1 Reply Like

Posted 6 years ago

  • 1
Photo of Brendan Hayes

Brendan Hayes, Official Rep

  • 962 Posts
  • 122 Reply Likes
It seems there's a missed node in the traversal: "moon_phase"

This should work:
sunrise = parsed_json ['moon_phase']['sunrise']['hour']