我有这样一个网址:
http://idebate.org/debatabase/debates/constitutional-governance/house-supports-dalai-lama%E2%80%99s-%E2%80%98third-way%E2%80%99-tibet
然后我在python中使用以下脚本来解码此url:
full_href = urllib.unquote(full_href.encode('ascii')).decode('utf-8')
然而,我得到了这样的错误:
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 89: ordinal not in range(128)
尝试写入文件时
就像@凯文杰。蔡斯指出,您很可能试图用不兼容的ascii格式的字符串写入文件。 您可以更改写入文件编码,也可以将
full_href
编码为ascii
,如下所示:或者
相关问题 更多 >
编程相关推荐