我最近开始研究 Google 应用引擎,并面临以下问题:
我有一个 main.py,我的用户可以在其中看到他自己的评论和其他人的评论。现在,我需要添加一个 EditComment.py,当用户想要编辑代码时会在其中进行引导。
我仅使用留言簿应用程序,要实际获取所选评论,我需要留言簿名称和评论内容。我如何创建这个网址?
换句话说,我需要创建一个像这样的网址
\edit?guestbook="Family"&content="helloworld"
我试过了
//I need to send guestbook_name and content of greeting in order to fetch the row from
//the database
//So, I show the text of the greeting and give a url to edit page
content_toSend = {'guestbook_name':guestbook_name,'content':greeting.content}
self.response.write('<blockquote><a href="/edit?%s">%s</a></blockquote>' %
(content_toSend,greeting.content))
//But the other side handler receives only the first variable of the dict in the get request
以便用户可以单击问候语并定向到编辑页面。但 get 请求只发送 url 中的第一个 var(guestbook_name)。如何发送整本词典?
编辑:我厌倦了 urllib.urlencode 但 webapp2 中的处理程序需要一个字典,所以这不起作用
最佳答案
方法urlencode()
urllib
标准库很有用。
编辑示例:
content_toSend = urllib.urlencode({
'guestbook_name' : guestbook_name,
'content' : greeting.content
})
关于python - 通过谷歌应用引擎中的 get 发送多变量字典; Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20037426/