Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python IDNA nameprep无效字符u'\x94和x27;_Python_Unicode_Encoding - Fatal编程技术网

Python IDNA nameprep无效字符u'\x94和x27;

Python IDNA nameprep无效字符u'\x94和x27;,python,unicode,encoding,Python,Unicode,Encoding,我有一些使用unicode的工作url,并尝试应用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") 上述代码在以下情况下失败: 文件“C:\Python25\lib

我有一些使用unicode的工作url,并尝试应用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")
上述代码在以下情况下失败:

文件“C:\Python25\lib\encodings\idna.py”,第38行,在nameprep中 引发Unicode错误(“无效字符%r”%c)Unicode错误:无效字符u'\x94'


我的编码有什么问题?

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

0080-009F;[控制字符]


@尤金-不?
/
之后的第二个字符是
%94
,它与
\x94
相同。好的,感谢它现在已转换,但现在我发现我错了:域名ASCII编码,但路径没有-IDNA没有帮助