JavaScript + python url-en/解码问题

发布于 2024-08-13 01:38:07 字数 465 浏览 2 评论 0原文

你好,我对 python 和 javascript 之间的 url 编码有点困惑,我希望你能帮助我:S

Javascript:

encodeURIComponent('lôl');
-> "l%C3%B4l"

Python:

import urllib
test = container.REQUEST.form.get('test')
print test
print urllib.unquote(test)
-> "lÃŽl"
-> "lÃŽl"

Javascript 编码“lôl”两次,但是 python 用它编码一次,我不知道如何从那里逃脱,因为我无论如何都会通过原型 HTTP GET 请求“l%C3%B4l”而不是“l%F4l”接收

最好的问候 纽约

**编辑 它位于 zope 网络服务器上

Hi there im kinda stucked with the url encoding between python and javascript, i hope you can help me out :S

Javascript:

encodeURIComponent('lôl');
-> "l%C3%B4l"

Python:

import urllib
test = container.REQUEST.form.get('test')
print test
print urllib.unquote(test)
-> "lÃŽl"
-> "lÃŽl"

Javascript encodes "lôl" twice however python does that once with it, i dunno how to escape from there because i receive anyway throgh the Prototype HTTP GET request "l%C3%B4l" instead of "l%F4l"

Best Regards
Bny

**edit
its on a zope webserver

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月亮邮递员 2024-08-20 01:38:07

zope 已经对其进行了 url 解码 - 问题是您正在获取 utf-8 字节字符串并将其打印在非 utf-8 终端上。尝试解码字符串。

x = 'l\xc3\xb4l'
unicode_x = x.decode('utf-8')
print unicode_x

zope already url-decodes it - issue is that you're getting a utf-8 bytestring and printing it on a non-utf-8 terminal. Try decoding the string.

x = 'l\xc3\xb4l'
unicode_x = x.decode('utf-8')
print unicode_x
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文