我的django项目遇到了问题。它如下:
获取结果:__init__() takes 1 positional argument but 2 were given
我的代码:
urls.py
url(r'^_get_weather', views._get_weather, name='_get_weather')
views.py
def _get_weather(request):
r = urllib.request.urlopen('http://api.openweathermap.org/data/2.5/weather?APPID=$API&q=Hongkong')
s = r.read().decode('utf-8')
j = json.loads(s)
temp='Current tempearture: {:.2f}'.format(j['main']['temp'] - 273.15)
return HttpRequest(temp)