python - 通过谷歌应用引擎中的 get 发送多变量字典; Python

标签 python google-app-engine get

我最近开始研究 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/

相关文章:

python - 在 Ipython Notebook 中禁用 INFO 日志记录消息

python - 示例项目的 Google App Engine "Error: Server Error"

python - 阻止机器人抓取我的 Google App Engine 网站

python - 无法理解应用引擎中的游标

hibernate - 使用 hibernate + spring mvc 获取自动生成的 key ,保存时

C# 设置和获取快捷方式属性

javascript - 使用 JQuery 提交 GET 表单时如何更改查询字符串?

python - 查找类别总数的百分比,从最高到最低排序,保留前 80% 的名称并将所有其他名称重命名为 'other'

python - CookieJarLib 不会将 cookie 保存回文件吗?

php - 改进了 PHP 的 sprintf