AttributeError: 'Request' object has no attribute 'params'

AttributeError: 'Request' object has no attribute 'params'

我在 python3、ubuntu.

上的 falcon 库中收到错误“AttributeError: 'Request' object has no attribute 'params'”

请求url = 127.0.0.1:8000/user?name=abc

from wsgiref import simple_server
import falcon

class user(object):
    def on_get(self, req, resp):
        print(req.params['name'])

api = application = falcon.API()

usr = user()
api.add_route('/user', usr)

if __name__ == '__main__':
    http = simple_server.make_server('127.0.0.10', 8000, api)
    http.serve_forever()

在上面的代码中我无法访问 req.params

如果您使用的是 1.0 版,请注意以下重大更改:

An option was added to toggle automatic parsing of form params. Falcon will no longer automatically parse, by default, requests that have the content type "application/x-www-form-urlencoded"...

Applications that require this functionality must re-enable it explicitly, by setting a new request option that was added for that purpose, per the example below:

app = falcon.API()
app.req_options.auto_parse_form_urlencoded = True

https://github.com/falconry/falcon/blob/master/CHANGES.rst