python编码报错1
2018-06-06 本文已影响0人
YoungPen
报错位置: f.write(title+','+link+'\n')
UnicodeEncodeError: 'gbk' codec can't encode character '\u30fb' in position 5: illegal multibyte sequence
解决办法:f = open('1.txt','w+',encoding='utf-8'),添加encoding编码为非默认
报错位置: f.write(title+','+link+'\n')
UnicodeEncodeError: 'gbk' codec can't encode character '\u30fb' in position 5: illegal multibyte sequence
解决办法:f = open('1.txt','w+',encoding='utf-8'),添加encoding编码为非默认