gpt4 book ai didi

python - IDNA nameprep 无效字符 u'\x94'

转载 作者:行者123 更新时间:2023-12-01 06:02:56 26 4
gpt4 key购买 nike

我有一些使用 unicode 的工作网址并尝试应用 IDNA 编码

test = ur"http://example.com/%D0%94%D0%B8%D1%81%D0%BA%D0%BE%D0%BD%D1%82-%D1%82%D0%B0%D0%BA%D1%81%D0%B8.22219/"
url_unq = urllib.unquote(test)
print url_unq
print url_unq.encode("idna")

上面的代码失败并显示:

File "C:\Python25\lib\encodings\idna.py", line 38, in nameprep raise UnicodeError("Invalid character %r" % c) UnicodeError: Invalid character u'\x94'

我的编码有什么问题?

最佳答案

这是因为 \x94 无法在 IDNA 中进行编码 - 请参阅 RFC3454 :

0080-009F; [CONTROL CHARACTERS]

关于python - IDNA nameprep 无效字符 u'\x94',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9360635/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com