标签: list python-3.x random
List1 = []
调用List1 随机导入
for n in range(1000): y = random.randrange(0,100000) List1.append(y) List2 = [] for n1 in range(1000): y1 = random.randrange(0,100000) List2.append(y1)
第一个列表,我想在#
答案 0 :(得分:1)
您可以使用sets和counters:
List2中的数字不在List1中:
set_of_different_numbers = set(List2) - set(List1)
List2中数字的出现:
from collections import Counter occurence_count = Counter(List2)
List2中不在List1中的数字的出现:
occurence_in_disjunction = Counter([l for l in List2 if l in set_of_different_numbers])