how can I print key and value form list of dictionaries in python
<p>how can I print key and id from the following in python</p>

<pre><code>[&lt;JIRA Issue: key=u'OPS-22158', id=u'566935'&gt;,
 &lt;JIRA Issue: key=u'OPS-22135', id=u'566480'&gt;,
 &lt;JIRA Issue: key=u'OPS-22131', id=u'566361'&gt;,
 &lt;JIRA Issue: key=u'OPS-21850', id=u'561948'&gt;,
 &lt;JIRA Issue: key=u'OPS-20967', id=u'533908'&gt;,
 ]
</code></pre>

<p>more information about the project.
I am trying to use jira api calls and as an example get list of issues created by a certain user:</p>

<pre><code>    from jira import JIRA
    from getpass import getpass
    from pprint import pprint 
    import csv

    def main():
        options = {
            'server': 'https://staging-jira.engsrv.mobileiron.com/',
        'verify': False
        }
        password = getpass()
        jira = JIRA(options, basic_auth=('hhaddadian', password))

        # Get the mutable application properties for this server (requires
        # jira-system-administrators permission)
        # props = jira.application_properties()

        # Find all issues reported by the admin
        issues = jira.search_issues('assignee=hhaddadian')
        pprint (issues) 
        for items in issues:
            print items 
if __name__ == "__main__":
    main()
</code></pre>

<p>and my result looks like this
[</p>

<pre><code>root@localhost ~]# python test.py 
Password: 
/usr/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py:838: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/security.html
  InsecureRequestWarning)
/usr/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py:838: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/security.html
  InsecureRequestWarning)
/usr/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py:838: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/security.html
  InsecureRequestWarning)
[&lt;JIRA Issue: key=u'OPS-22158', id=u'566935'&gt;,
 &lt;JIRA Issue: key=u'OPS-22135', id=u'566480'&gt;,
 &lt;JIRA Issue: key=u'OPS-22131', id=u'566361'&gt;,
 &lt;JIRA Issue: key=u'OPS-21850', id=u'561948'&gt;,
 &lt;JIRA Issue: key=u'OPS-20967', id=u'533908'&gt;,
 ]
OPS-22158
OPS-22135
OPS-22131
OPS-21850
OPS-20967
</code></pre>

<p>I was wondering what kind of data I am getting in return. and how can I print key and id also maybe converting the result to a csv file.</p>

<pre><code>import jira
# stuff

for issue in jira.search_issues('assignee=hhaddadian'):
    print(issue.fields.project.key)
</code></pre>

<p>The result of the jira.search_issues function is a list of Jira objects. These objects are defined here: <a href="https://jira.readthedocs.io/en/latest/" rel="nofollow">https://jira.readthedocs.io/en/latest/</a></p>

<p>If you want the whole object (every field) in JSON format:</p>

<pre><code>print(issue.raw)
</code></pre>

python python-2.7 dictionary