How to Get Key Values in Python

Whey you create an array in Python, the values in the array have numeric keys assigned to them that allow you to quickly pull out information based on its key value. If you need to know the key value of a particular array element, you can use a reverse lookup on the element to find out what key is assigned to it in the array.

Instructions

    • 1

      Note the value of the variable that holds the array in your Python application. For this example, the variable name is "$arrayVar".

    • 2

      Type "$lookupValue = 'my_lookup_value'" into the program, where "my_lookup_value" is the actual value that you want to use to perform a key lookup.

    • 3

      Type "new Mixed $keyValue = py.key($arrayVar,$lookupValue);" to look up the key value and assign it to the "$keyValue" variable.

Related Searches:

Comments

Related Ads

Featured