Python Crawler的JSON输出编码问题
无论爬取时是否进行解码与编码,最终作如下处理便可解决乱码的问题:
import codecs
json_output=json.dumps(text_content,ensure_ascii=False,indent=4) jsonfile = 'output.json' j =codecs.open(jsonfile,'w','utf-8') j.write(json_output) j.close()
无论爬取时是否进行解码与编码,最终作如下处理便可解决乱码的问题:
import codecs
json_output=json.dumps(text_content,ensure_ascii=False,indent=4) jsonfile = 'output.json' j =codecs.open(jsonfile,'w','utf-8') j.write(json_output) j.close()