Reputation: 6344
I am trying to extract historical weather data using wunderground python API, however I am repeatedly getting an error. Can some one please help out:
import requests
def get_precip(gooddate):
urlstart = 'http://api.wunderground.com/api/INSERT_KEY_HERE/history_'
urlend = '/q/Switzerland/Zurich.json'
url = urlstart + str(gooddate) + urlend
data = requests.get(url).json()
for summary in data['history']['dailysummary']:
print ','.join((gooddate,summary['date']['year'],summary['date']['mon'],summary['date']['mday'],summary['precipm'], summary['maxtempm'], summary['meantempm'],summary['mintempm']))
Error:
File "<ipython-input-49-802c58ba5307>", line 9
print ','.join((gooddate,summary['date']['year'],summary['date']['mon'],summary['date']['mday'],summary['precipm'],'maxtempm',summary['meantempm'],summary['mintempm']))
^
SyntaxError: invalid syntax
Upvotes: 0
Views: 1311
Reputation: 309049
If you are using Python 3, print is a function, not a statement, and requires parentheses.
print(','.join((gooddate,summary['date']['year'],summary['date']['mon'],summary['date']['mday'],summary['precipm'], summary['maxtempm'], summary['meantempm'],summary['mintempm'])))
Upvotes: 3