Python Peewee查询结果,unicode数据与列表中的常规字符串不可比较

Python Peewee查询结果,unicode数据与列表中的常规字符串不可比较,python,unicode,peewee,Python,Unicode,Peewee,我使用peewee生成了一个查询: nameGoEvidenceEarlier = Protein.select(Protein.entryname ,Evidence.evidencecode ,Go.go_domain, Go.go_term).join(ProteinGo).join(Evidence).switch(ProteinGo).join(Go).where(Evidence.ondate.year == 2013).order_by(Protein.entryname).nai

我使用peewee生成了一个查询:

nameGoEvidenceEarlier = Protein.select(Protein.entryname ,Evidence.evidencecode ,Go.go_domain, Go.go_term).join(ProteinGo).join(Evidence).switch(ProteinGo).join(Go).where(Evidence.ondate.year == 2013).order_by(Protein.entryname).naive()
然后我迭代查询结果:

for earlier in nameGoEvidenceEarlier.iterator():
earlierDict[earlier.entryname] = earlierDict.get(earlier.entryname,[]) + [(earlier.go_domain,earlier.evidencecode,earlier.go_term)] 
列表包含以下项目:

nonexpEvidenceList = ['IEA','ISS','ISO','ISA','ISM','IGC','IBA','IBD','IKR','IRD','RCA','TAS','NAS','IC','ND']
然后,我遍历字典earlierDict并进行比较,以查看元组的第一个值(前面的.belicenceCode)是否在非ExplicenceList中:

for entryname,earlier_ontologyCodeTermList in earlierDict.items():
for o,c,t in earlier_ontologyCodeTermList:
    if c.encode('ascii') in nonexpEvidenceList:
       print c
但是,这段代码不打印任何内容。我们可以得出一个明显的结论,c不存在于非证据列表中,但事实并非如此——当我打印c时,列表中所有可用的代码都存在。 我猜这个类型的铸造在什么地方出了问题


我是否忽略了什么?

如果将打印类型(c)作为for循环的第一行,那么打印类型(c)会显示什么<代码>?此外,Martijn Pieter对的回答可能很有启发性。jedwards:循环第一行中的打印类型(c)显示Unicode类型当您可能需要
时,如果非扩展证据列表中的c.encode()为
,其中
是数据库的编码(例如
UTF-8
,等等).它将如何将c与具有常规ascii符号的列表进行比较?