可切片字典
slict的Python项目详细描述
支持切片的字典。
slct实现映射并接受[start]:[stop]索引,以便沿着元组键的一个或多个维度对其进行切片。
slct可以包装任何其他python映射,并且是轻量级的(空间上是o(1))。例如,用chest试试。
示例
>>>fromslictimportSlict>>>weather=Slict({("12pm","Temperature"):15.,("12pm","Wind Speed"):12.5,...("1pm","Temperature"):15.5,("1pm","Wind Speed"):9.2})>>>temps=weather[:,"Temperature"]>>>forkintemps:...print("The temperature at {:4s} is {:f}".format(k,temps[k]))Thetemperatureat12pmis15.000000Thetemperatureat1pmis15.500000>>>noon_weather=weather["12pm",:]>>>forkinnoon_weather:...print("The {:s} is {:f}".format(k,noon_weather[k]))TheTemperatureis15.000000TheWindSpeedis12.500000
安装
slict在python包索引(pypi)上:
pip install slict