【发布时间】:2018-05-01 11:07:32
【问题描述】:
我有两个列表
list1 = ["foo", "bar"]
list2 = ["foo", "bar"]
我有一个比较两个字符串的方法text_match:
def text_match(self, expected, actual):
if expected == actual:
return True
else:
return False
我调用方法
self.text_match(list1[0], list2[0])
我错了。
当我从列表中打印两个字符串时
list1[0] >> foo
list2[1] >> u"foo"
为什么它们在打印时不一样? 我试过编码、解码、转换为字符串。 没有任何效果。
有什么想法吗?
【问题讨论】:
标签: string python-2.7 list compare