python3中存csv乱码的问题:
with open(filename, 'a', newline='', encoding='utf-8-sig') as f: # 中文需要设置成utf-8格式
open()增加encoding得设置即可(python2不支持)
python2中中文乱码问题:
用记事本打开导出得csv文件,另存为,并且选择编码为utf-8
csv导出文件有空行得问题(每隔一行有一行空行)
python3的处理方式:with open(filename, 'a', newline='', newline='') as f:
python2的处理方式(适合追加写入):with open(filename, 'ab+') as f:
python2的处理方式(一次性写入):with open(filename, 'wb') as f: