V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
ergatea
V2EX  ›  RQ

Rq 执行的的任务貌似对中文支持不佳

  •  
  •   ergatea · 2013-02-02 20:20:59 +08:00 · 6428 次点击
    这是一个创建于 4094 天前的主题,其中的信息可能已经有所发展或是发生改变。
    def fetch_post_request(path, post):
    http = tornado.httpclient.HTTPClient()

    if not obj:
    obj = db.Post()
    else:

    if 'hash' in obj['metadata'].keys():
    uri = "http://localhost:5000/%s/post/%s?cmd=original&hash=%s" % \
    (path, slug, obj.metadata['hash'])

    try:
    response = http.fetch(uri)

    print unicode(uri, "utf-8")
    response.rethrow()
    obj.body = unicode(response.body, "utf-8")
    print json.loads(response.headers["x-dropbox-metadata"])
    obj.metadata = json.loads(response.headers["x-dropbox-metadata"])
    obj.save()
    =====
    通过 tornado.httpclient.HTTPClient() 的代码 在执行过程中带有中文url路径就不能处理编码
    1 条回复    1970-01-01 08:00:00 +08:00
    notedit
        1
    notedit  
       2013-02-02 20:55:12 +08:00
    记得urlencode 一下
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1753 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 16:35 · PVG 00:35 · LAX 09:35 · JFK 12:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.