python UnicodeEncodeError: 'gbk' codec can't encode character u'\ufeff'

windows7上,cmd窗口默认编码为gbk,输出文本又包含非法字符,

解决方法:

文本.encode('utf-8','ignore');

ignore为忽略那些非法字符。

你可能感兴趣的:(python UnicodeEncodeError: 'gbk' codec can't encode character u'\ufeff')