📜  范围内的python字典键 - Python代码示例

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

代码示例1
myDict = {
    (float('-inf'), 12): "child",
    (13, 19): "teen",
    (20, 65): "adult",
    (66, float("inf")): "senior"
}

testValue = 10

for (k1, k2) in myDict:
    if (k1 < testValue and k2 > testValue):
         result = myDict[(k1,k2)]