請教像我這么做有什么簡便的方法沒?
s?=?set(['Adam',?'Lisa',?'Paul']) L?=?['Adam',?'Lisa',?'Bart',?'Paul'] temp?=?set([]) for?a?in?s: ????for?b?in?L: ????????if?a?!=?b: ????????????temp.add(b) for?a?in?s: ????for?b?in?L: ????????if?a?==?b: ????????????temp.remove(b) s?=?temp print?s
2015-05-06
不需要遍歷每個元素然后進行==比較,
用in就能夠判斷元素是不是在s里了。
2015-05-04
想了下 temp完全無用 就這樣吧.