설치 방법

pip install range-key-dict


사용법

from range_key_dict import RangeKeyDict


range_dict = RangeKeyDict({

(0.5, 104.12): 'apple',

(104.12, 232): 'tomato',

(232, 400): 'banana'

})


range_dict[50] # 'apple'

range_dict.get(300.51, 'none') # 'banana'

range_dict.get(1000, 'none') # 'none'


+ Recent posts