碰到个循环中if判断的问题(内附代码)(我脑残了。。吸取教训以后遇问题多思考)
没事了,不好意思~脑残了 *********** s = set(['Adam', 'Lisa', 'Paul']) L = ['Adam', 'Lisa', 'Bart', 'Paul'] judge=0 for i in L: print i for x in s: if x == i: judge = True print judge Adam True Lisa True Bart #!!!返回是True? True Paul True 而当我把if x == i: 改成 if x == 'Bart'
Adam 0 Lisa 0 Bart 0 Paul 0 结果又正常了,没搞明白