# 取 dict 的交集 (September 18, 2024)

大概这样的效果：

![](/nlark/yuque/0/2024/png/26070246/1726661125993-41c1e3f5-a077-462d-9e3b-0f459879a175.png)

实现：

```python
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://python.promplate.dev/telegraph/computed-styles-09-18](https://python.promplate.dev/telegraph/computed-styles-09-18)

<iframe src="https://python.promplate.dev/telegraph/computed-styles-09-18"></iframe>