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)
ビュー関数はではHttpResponse
なくを返す必要がありHttpRequest
ます。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加