Heim  >  Fragen und Antworten  >  Hauptteil

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

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

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

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

迷茫迷茫2741 Tage vor696

Antworte allen(2)Ich werde antworten

  • ringa_lee

    ringa_lee2017-04-18 10:29:02

    可以在打印的地方试试title.encode(utf8)

    Antwort
    0
  • 巴扎黑

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

    str()不能转换Unicode字符串,unicode转str要用encode()。文件名字换一个。

    Antwort
    0
  • StornierenAntwort