-2
我不需要备用解决方案。str.endwith()在有效检查中返回false
我正在使用Python 2.5.4并且想知道为什么会发生这种情况。
我为makefile编写源码解析器。
ff = open("module.mk")
f = ff.readlines()
ff.close()
for i in f:
if ".o \\" in i[-5:]:
print "Is %s for str: %s" %(i.endswith('.o \\'), i)
我:
Is False for str: bitmap.o \
所以每一个检查。
当你使用它.readlines()
包括在这种情况下,在该行的换行符,CR-LF你可以从github
'i'上有空白。试试'i.strip()。endswith('。o \\')'。在完全分开的说明中,为什么仍然使用2.5.4? –
这将是一个很好的答案,@MorganThrapp。 –
@ morgan-thrapp,大部分解析器代码写在我的手机上。 Qpython上的android buggy,在诺基亚pys60上工作正常,我选择pys60。基于2.5.4核心的最后一款pys60。 – Fedor