UnicodeEncodeError: 'gbk' codec can't encode character '\xeb' in position 20: illegal multibyte sequ
生活随笔
收集整理的這篇文章主要介紹了
UnicodeEncodeError: 'gbk' codec can't encode character '\xeb' in position 20: illegal multibyte sequ
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
源代碼:with open (os.path.join(self.root,filename),mode=‘w’,newline=’’) as f:
writer=csv.writer(f)
for img in images:
name=img.split(os.sep)[-2]
label=self.name2lable[name]
writer.writerow([img,label])
解決方法 在open()里面加入 encoding=‘utf-8’ 即可
總結
以上是生活随笔為你收集整理的UnicodeEncodeError: 'gbk' codec can't encode character '\xeb' in position 20: illegal multibyte sequ的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Nexus搭建Maven私有仓库
- 下一篇: 腾讯云ubuntu18安装图形化界面