python字符串不能比较解决方案

python字符串不能比较s1self.choice14.GetStringSelection().encode(utf-8)y[是.decode(utf-8),

python字符串不能比较
s1=self.choice14.GetStringSelection().encode('utf-8')
  y=['是'.decode('utf-8'),'否'.decode('utf-8')]
  if s1==y[0]:
  t8='1'
  else:
  t8='0'

File "D:\程序\python\lionogram_measure.py", line 3778
  if s1==y[0]:
UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal

[解决办法]

探讨
在比较的时候,编码要一致:
'是'.decode('utf-8') #这是unicode编码

而:s1=self.choice14.GetStringSelection().encode('utf-8') #这是utf8编码
要比较就这样吧:

s1=self.choice14.GetStringSelection().encode('utf-8')
y=[u'是'.encode(……