在python中,两个路由字符串相互追加
在下面的代码中在python中,两个路由字符串相互追加,python,google-app-engine,Python,Google App Engine,在下面的代码中location\u id=“Roger”和court\u id=“court1” 其中get定义如下 class Schedule(BaseHandler): def get(self, location_id, court_id): self.render_template('schedule.html', {'location':location_id,'court':court_id}) 但是当我使用以下路由到达schedule.html模板时 a
location\u id=“Roger”
和court\u id=“court1”
其中get定义如下
class Schedule(BaseHandler):
def get(self, location_id, court_id):
self.render_template('schedule.html', {'location':location_id,'court':court_id})
但是当我使用以下路由到达schedule.html模板时
app = webapp2.WSGIApplication([
('/', MainPage),
('/create/([\w]+)', CreateCourt),
('/createlocation/([\w]+)', CreateLocation),
('/schedule/([\w]+/([\w]+))', Schedule)
],
debug=True)
位置
的价值已经增长到包括一个/
和法庭
的价值:“罗杰/法庭1”
如何将“场地/场地”的两个部分分开?
我怀疑答案与/schedule的路由regexp有关。我认为你是对的-在你的
schedule
处理程序中,看起来你缺少了右括号(以前从未键入过单数-奇怪:)。试试这个:
app = webapp2.WSGIApplication([
('/', MainPage),
('/create/([\w]+)', CreateCourt),
('/createlocation/([\w]+)', CreateLocation),
('/schedule/([\w]+)/([\w]+)', Schedule)
],
debug=True)
我认为你是对的-在你的
日程安排
处理程序中,看起来你缺少了右括号(以前从未键入过单数-奇怪:)。试试这个:
app = webapp2.WSGIApplication([
('/', MainPage),
('/create/([\w]+)', CreateCourt),
('/createlocation/([\w]+)', CreateLocation),
('/schedule/([\w]+)/([\w]+)', Schedule)
],
debug=True)
是的,这就是问题所在。即使你用一个额外的“')来纠正错误。但重要的部分你做对了<代码>('/schedule/([\w]+)/([\w]+),schedule)谢谢。哈哈,更正了(regex总是让我头晕目眩)。很高兴它能起作用。是的,这就是问题所在。即使你用一个额外的“')来纠正错误。但重要的部分你做对了<代码>('/schedule/([\w]+)/([\w]+),schedule)谢谢。哈哈,更正了(regex总是让我头晕目眩)。很高兴它起作用了。