{"id":239,"date":"2018-06-21T17:25:49","date_gmt":"2018-06-21T17:25:49","guid":{"rendered":"http:\/\/python.wp.w3.pt\/?p=239"},"modified":"2018-06-21T17:25:49","modified_gmt":"2018-06-21T17:25:49","slug":"python-e-json","status":"publish","type":"post","link":"http:\/\/python.w3.pt\/?p=239","title":{"rendered":"Python e JSON"},"content":{"rendered":"<p>Eis um primeiro exemplo de cria\u00e7\u00e3o de uma string JSON, que cont\u00e9m duas listas, em Python:<\/p>\n<pre>\r\n#!\/usr\/bin\/python\r\n# -*- coding: utf-8 -*-\r\nimport json\r\n\r\nlista1 = [3,4,-2,0,17]\r\nlista2 = [\"Abel\", \"Maria\", \"Carolina\", \"Zeca\"]\r\n\r\nimport json\r\ndata = {}\r\ndata['num'] = lista1\r\ndata['name'] = lista2\r\ns = json.dumps(data)\r\nprint s\r\n<\/pre>\n<p>cujo output \u00e9:<\/p>\n<pre>\r\n{\"num\": [3, 4, -2, 0, 17], \"name\": [\"Abel\", \"Maria\", \"Carolina\", \"Zeca\"]}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Eis um primeiro exemplo de cria\u00e7\u00e3o de uma string JSON, que cont\u00e9m duas listas, em Python: #!\/usr\/bin\/python # -*- coding: utf-8 -*- import json lista1 = [3,4,-2,0,17] lista2 = [&#8220;Abel&#8221;, &#8220;Maria&#8221;, &#8220;Carolina&#8221;, &#8220;Zeca&#8221;] import json data = {} data[&#8216;num&#8217;] = lista1 data[&#8216;name&#8217;] = lista2 s = json.dumps(data) print s cujo output \u00e9: {&#8220;num&#8221;: [3, 4, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/python.w3.pt\/?p=239\" class=\"more-link\">Continuar a ler <span class=\"screen-reader-text\">&#8220;Python e JSON&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/posts\/239"}],"collection":[{"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/python.w3.pt\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=239"}],"version-history":[{"count":1,"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/posts\/239\/revisions"}],"predecessor-version":[{"id":240,"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/posts\/239\/revisions\/240"}],"wp:attachment":[{"href":"http:\/\/python.w3.pt\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/python.w3.pt\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=239"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/python.w3.pt\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}