今天爬一个网站的内容,在写入文件时,某些页面总是报UnicodeEncodeError: ‘gbk’ codec can’t encode character错误,网上找了半天也没找到解决办法。
后来终于找到了解决办法,十分简单:
with open('dizhi.txt','w',encoding='utf-8') as f:
with open('dizhi.txt','w',encoding='utf-8') as f:
转载于:https://www.cnblogs.com/zbuter/p/8781194.html