Apr-18-2019, 07:17 PM
I changed the function is:
def found_location(self, request, data): data = json.loads(data.decode()) if not isinstance(data, dict) else data print(type(data), data) cities = ["{} ({})".format(d['name'], d['sys']['country']) for d in data['list']] self.search_results.item_strings = citiesThe result is:
You searched for: 'Vancouver' <class 'dict'> {'coord': {'lon': -122.67, 'lat': 45.63}, 'weather': [{'id': 500, 'main': 'Rain', 'description': 'light rain', 'icon': '10d'}], 'base': 'stations', 'main': {'temp': 292.03, 'pressure': 1023, 'humidity': 55, 'temp_min': 289.15, 'temp_max': 294.26}, 'visibility': 16093, 'wind': {'speed': 1.5, 'deg': 360}, 'rain': {'1h': 0.25}, 'clouds': {'all': 40}, 'dt': 1555614246, 'sys': {'type': 1, 'id': 5321, 'message': 0.0088, 'country': 'US', 'sunrise': 1555593581, 'sunset': 1555642796}, 'id': 5814616, 'name': 'Vancouver', 'cod': 200} Traceback (most recent call last): ... etc