Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么得到类型错误:接受1个位置参数,但给出2个位置参数?_Python_Django - Fatal编程技术网

Python 为什么得到类型错误:接受1个位置参数,但给出2个位置参数?

Python 为什么得到类型错误:接受1个位置参数,但给出2个位置参数?,python,django,Python,Django,我的django项目遇到了一个问题。详情如下: 获取结果:uuu init_uuuu接受1个位置参数,但给出了2个 我的代码: url.py views.py 视图函数应返回not an。视图函数应返回not an url(r'^_get_weather', views._get_weather, name='_get_weather') def _get_weather(request): r = urllib.request.urlopen('http://api.openweat

我的django项目遇到了一个问题。详情如下:

获取结果:uuu init_uuuu接受1个位置参数,但给出了2个

我的代码:

url.py

views.py


视图函数应返回not an。

视图函数应返回not an

url(r'^_get_weather', views._get_weather, name='_get_weather')
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)