Using a variable to replace an integer? (Except it isn't working!) - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Using a variable to replace an integer? (Except it isn't working!) (/thread-4130.html) Pages:
1
2
|
RE: Using a variable to replace an integer? (Except it isn't working!) - s1monsays - Jul-25-2017 Attempt: #note: the url is actually there in the code, but it was preventing me from posting this url = 'freegeoip' try: with closing(urlopen(url)) as response: location = json.loads(response.read()) loc_c = location['city'] loc_s = location['region_name'] except: print('step 1 failed') client = yweather.Client() wid = client.fetch_woeid('loc_c, loc_s') print(wid) print('steps 1 and 2 finished') print('step 3 started') loc_weather = client.fetch_weather(wid) loc_weather["condition"]["text"] loc_weather["condition"]["temp"] print('step 3 finished')Also while I was typing this, a new traceback popped up:
RE: Using a variable to replace an integer? (Except it isn't working!) - buran - Jul-25-2017 As I said you need to change also line 12 wid = client.fetch_woeid('loc_c, loc_s')should be wid = client.fetch_woeid("{}, {}".format(loc_c, loc_s)) RE: Using a variable to replace an integer? (Except it isn't working!) - s1monsays - Jul-25-2017 Tried that as well. New traceback:
RE: Using a variable to replace an integer? (Except it isn't working!) - buran - Jul-25-2017 always post the code, the output and like you did - the full traceback. what was the output from print (wid) RE: Using a variable to replace an integer? (Except it isn't working!) - buran - Jul-25-2017 well, now I went to github repo of yweather package it saysYahoo Weather has discontinued the RSS feed interface this library is based on. There is a new YQL Query interface: https://developer.yahoo.com/weather/ I don't plan on updating this library to use the new endpoint. any reason why you expect it to work? RE: Using a variable to replace an integer? (Except it isn't working!) - s1monsays - Jul-25-2017 (Jul-25-2017, 06:39 PM)buran Wrote: always post the code, the output and like you did - the full traceback. The print(wid) gave me "2449574" which is the correct woe_id for where I live, so that part definitely works! (At least I got the first part right, haha) |