web.py url传参及获取
第一种:直接获取;
import web urls = ( '/(.*)','index' #URL后面必须加(.*) ) class index: def GET(self,name): print name #name=mona return 123 if __name__ == "__main__": app = web.application(urls, globals()) app.run() #访问URL为http://0.0.0.0:8080/mona
第二种:web.input获取:
import web urls = ( '/(.*)','index' ) class index: def GET(self,name): h = web.input() print h.name # h 是web.utils.Storage对象,可以h.name取值也可以h['name']取值 return 123 if __name__ == "__main__": app = web.application(urls, globals()) app.run() #访问URL:http://0.0.0.0:8080/?name=mona