问题:在代码中添加encoding=‘utf-8’,输出的CSV文件中的中午突然乱码
代码:
with open(root_path + '中文.csv'.format(today, city), 'a', newline='',encoding='utf-8') as f: write = csv.writer(f) write.writerow(['哈哈哈哈哈'])
解决方案:删除encoding=‘utf-8’
12-06
577
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-01
2548
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-30
3122
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-30
599
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-04
1189
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)