📜  python 获取字典的一部分 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:09.172000             🧑  作者: Mango

代码示例1
a_dictionary = {"a": 1, "b": 2, "c": 3, "d": 4}

a_subset = {key: value for key, value in a_dictionary.items() if value > 2}

print(a_subset)

# Output:
# {'c': 3, 'd': 4}