Not(condtion)vs!=之间的区别

时间:2018-05-24 14:53:02

标签: sql postgresql

SQL中not ([col] = any [collection])[col] != all [collection]之间有什么区别?

更具体地说,在PostgreSQL中。

1 个答案:

答案 0 :(得分:1)

他们是一样的。看看import itertools def has_straight(d): cards = {'J': 11, 'K': 13, 'T': 10, 'Q': 12} mutated_cards = list(map(lambda x:int(cards.get(x, x)), d)) _grouped = [list(b) for _, b in itertools.groupby(mutated_cards)] subs = list(filter(None, [_grouped[b:i] for i in range(len(_grouped)+1) for b in range(len(_grouped)+1)])) final_filtered = list(filter(lambda x:all(x[i+1][0] - x[i][0] == 1 for i in range(len(x)-1)), subs)) new_subs = [] if not final_filtered else max(final_filtered, key=lambda x:sum(len(i) for i in x)) return sum(len(i) for i in new_subs if len(i) > 1), list(map(lambda x:x[0], new_subs)) print(has_straight(['6', '8', '8', '9', 'T'])) print(has_straight(['4', '4', '5', '5', '6']))

(2, [8, 9, 10])
(4, [4, 5, 6])