I have output like this
>>> print output
[{u'MachineId': u'0', u'Stdout': u'{"version":"2.1-beta2.1-xenial-amd64","url":"file:///tmp/juju-tools137740170/tools/released/juju-2.1-beta2-xenial-amd64.tgz","sha256":"70a1ec4e9d194f71506b9b2944357335d3dbe5386e7797de3ed71c12092ba774","size":24537713}'}]
>>> type (output)
<type 'list'>
>>> print output[0]
{u'MachineId': u'0', u'Stdout': u'{"version":"2.1-beta2.1-xenial-amd64","url":"file:///tmp/juju-tools137740170/tools/released/juju-2.1-beta2-xenial-amd64.tgz","sha256":"70a1ec4e9d194f71506b9b2944357335d3dbe5386e7797de3ed71c12092ba774","size":24537713}'}
>>>
>>> type (output[0])
<type 'dict'>
In this I want to fetch sha256 value from the dictionary of output[0] and Stdout dict; Let me know is there a direct way to fetch this value in Python instead of iterating.
I got "TypeError: string indices must be integers" if I try to access them directly
>>> print output[0]['Stdout']['sha256']
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: string indices must be integers