Google App Engine - Request class query_string

前端 未结 2 1254
一个人的身影
一个人的身影 2021-01-05 14:44

In Python and GAE, I would like to ask how to get the parameters of a query string in the url. As I know, the query_string part returns all the part after the \"?\" in the

相关标签:
2条回答
  • 2021-01-05 14:47

    If you want to iterate over all the parameters of your request, you should do something like this:

    for argument in self.request.arguments():
        values = self.request.get_all(argument)
        # do something with values (which is a list)
    

    Or, you could build your own dict containing all the data:

    params = {arg: self.request.get_all(arg) for arg in self.request.arguments()}
    
    0 讨论(0)
  • 2021-01-05 14:57

    You don't need to complicate. You can retrieve all GET parameters with:

    self.request.get('var_name')
    

    Or if you want to retrieve them all in one list you can use:

    self.request.get_all()
    

    You can find more info on the Request class here.

    0 讨论(0)
提交回复
热议问题