Tuple usage

For example, we have a collection of e-mail addresses (haystack), but also to maintain a small collection of e-mail address (needles), and then find the needles in the number of address also appears in the heystack years. With a collection operation, we only need one line of code on it
The number of needles in the haystack elements appear, the two types of variables are set
found = len(needles & haystack)
found = 0
for n in needles:
    if n in haystack:
        found += 1    

 

Guess you like

Origin www.cnblogs.com/xiangxiaolin/p/11598137.html