1
我目前有一个域名列表,其中一些是国际化的。试图解码国际化的网址
例如一个与此xn--nqv7f.com
结束,但我希望它显示这样机构.com
我尝试它编码为ascii
和utf-8
,但我似乎无法得到控制台或我的网站上打印出来喜欢这个。我使用python 3.5
'xn--nqv7f.com'.decode('utf-8')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'decode'
,当我尝试这个,我只得到这个
'xn--nqv7f.com'.encode("idna")
b'xn--nqv7f.com'