Home  >  Q&A  >  body text

Python 爬虫字符编码问题,求解。

1处打印出来的在3处翻译过来大概是下图

2出报错在4处,求解Python编码问题

加了encode('utf-8')之后上面的好了,但在以path为文件名创建文件夹时报WindowsError(123)错误

迷茫迷茫2741 days ago698

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-04-18 10:29:02

    You can try title.encode(utf8) in the printing place

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-18 10:29:02

    str() cannot convert Unicode strings. To convert unicode to str, use encode(). Change the file name.

    reply
    0
  • Cancelreply