比较简单,就直接上代码了:

import web
urls = (
    '/', 'hello'
)
app = web.application(urls, globals())
class hello:        
    def GET(self):
        print web.input()
        return "GET hello world"
    def POST(self):
        print web.input()
        return "POST hello world"
if __name__ == '__main__':
    app.run()

将这段代码保存后运行。之后在浏览器中输入:

http://127.0.0.1:8080/?name=instant7&passward=ins&date=2014.11.4

就可以在python控制台看到如下记录:

<Storage {'date': u'2014.11.4', 'name': u'instant7', 'passward': u'ins'}>
127.0.0.1:16193 - - [04/Nov/2014 14:34:20] "HTTP/1.1 GET /" - 200 OK

至此,成功拿到get参数

如果想在代码中获取某一参数值,参考以下示例:

i = web.input()
name = i.name
password = i.password
date = i.date
print name, password, date

  

相关文章:

  • 2022-12-23
  • 2021-06-02
  • 2022-12-23
  • 2022-12-23
  • 2021-09-26
  • 2022-12-23
  • 2021-10-17
  • 2021-08-07
猜你喜欢
  • 2022-01-10
  • 2021-12-18
  • 2021-12-19
  • 2021-06-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案