我在这一行有一个与 Unicode 相关的问题:
strToCompare = str(self.modelProxy.data(cellIndex, Qt.DisplayRole).toString()).lower()
错误是:
UnicodeEncodeError:'ascii' 编解码器无法在位置 5 编码字符 u'\xe9':序数不在范围内(128)
这是因为数据是从数据库中可能包含 unicode 字符的字段中检索的。即使我添加了unicode()
转换为 Unicode 的功能,错误仍然存在。