http://stackoverflow.com/questions/18337407/saving-utf-8-texts-in-json-dumps-as-utf8-not-as-u-escape-sequence 里面有提到,将 JSONEncoder 的 ensure_ascii 参数设为 False 即可。

而 scrapy 的 item export 文档里有提到

The additional constructor arguments are passed to the
BaseItemExporter constructor, and the leftover arguments to the
JSONEncoder constructor, so you can use any JSONEncoder constructor
argument to customize this exporter.

因此就在调用 scrapy.contrib.exporter.JsonItemExporter 的时候额外指定 ensure_ascii=False 就可以啦。

无谓的信仰 answered 9 years, 11 months ago

存储为中为编码的问题可能较多,一般处理编码的问题在下列地方

  1. json要实现对文件的encode
  2. 下载的时候吸入数据到item时要decode
  3. 最关键的是在解析为后获得为列表数据时,还不能对列表decode
神秘君17号 answered 9 years, 2 months ago

Your Answer