NumPy slice notation in a dictionary
问题 I wonder if it is possible to store numpy slice notation in a python dictionary. Something like: lookup = {0:[:540], 30:[540:1080], 60:[1080:]} It is possible to use native python slice syntax, e.g. slice(0,10,2) , but I have not been able to store more complex slices. For example, something that is multidimensional [:,:2,:, :540] . My current work around is to store the values as tuples and then unpack these into the necessary slices. Working in Python 2.x. 回答1: The syntax [:, :2, :, :540]