取 dict 的交集

大概这样的效果:实现:from collections import Counter def merge_computed_styles(computed_styles: list[dict[str, str]]): counter = Counter() for styl...

大概这样的效果:

实现:

from collections import Counter

def merge_computed_styles(computed_styles: list[dict[str, str]]):
    counter = Counter()

    for style in computed_styles:
        counter.update(style.items())

    return dict([pair for pair, count in counter.items() if count == len(computed_styles)])

在线尝试:

https://bnu.py3.online/telegraph/computed-styles-09-18