字符串比较 - 不会产生所需的结果

时间:2014-11-12 12:56:57

标签: python string pandas

我有一只大熊猫dataframe

print type(opp.columns[0])
print type('region')

结果:

<type 'str'>
<type 'str'>

print opp.columns[0]

生成region

我已经验证了带有strip函数的字符串中没有其他空格。 但是:

print (opps.columns[0].strip() == 'region')

给出False

1 个答案:

答案 0 :(得分:1)

您可以使用repr方法来识别您获得的实际字符串值。可能存在"\n"等隐藏字符,这些字符不可见

repr(opportunities.columns[0])
相关问题