标签: python string pandas
我有一只大熊猫dataframe
dataframe
print type(opp.columns[0]) print type('region')
结果:
<type 'str'> <type 'str'>
和
print opp.columns[0]
生成region
region
我已经验证了带有strip函数的字符串中没有其他空格。 但是:
print (opps.columns[0].strip() == 'region')
给出False
False
答案 0 :(得分:1)
您可以使用repr方法来识别您获得的实际字符串值。可能存在"\n"等隐藏字符,这些字符不可见
repr
"\n"
repr(opportunities.columns[0])