http://docs.python.org/howto/unipre.html#the-unipre-
type
str = unipre(str, errors='replace')
要么
str = unipre(str, errors='ignore')
注意: 这将删除(忽略)有问题的字符,并返回不包含这些字符的字符串。
对我而言,这是理想的情况,因为我将其用作针对非ASCII输入的保护,这是我的应用程序所不允许的。
或者:
使用
precs模块中的open方法读取文件:
import precswith precs.open(file_name, 'r', encoding='utf-8', errors='ignore') as fdata:



