Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python 2.7从JSON API提取数据_Python_Json - Fatal编程技术网

使用Python 2.7从JSON API提取数据

使用Python 2.7从JSON API提取数据,python,json,Python,Json,这是我的php代码 php代码运行良好 $json = file_get_contents('http://examole.com/api.php'); $obj = json_decode($json,true); foreach($obj as $row) { echo ( $row["first_name"] ); echo "<br>"; } 在您的示例中,您没有使用从JSON文本加载的对象。 你应该试试这个 data = result.get

这是我的php代码 php代码运行良好

$json = file_get_contents('http://examole.com/api.php');
$obj = json_decode($json,true);
foreach($obj as $row)
{
       echo ( $row["first_name"] );

       echo "<br>";
}

在您的示例中,您没有使用从JSON文本加载的对象。 你应该试试这个

data = result.get("first_name").get("data")

有什么问题?还附加一个示例JSON,您正在尝试解析Python文件not work i get IOError:[Errno socket error][Errno 110]连接超时此错误然后如何解决此问题存在一些问题
data = result.get("first_name").get("data")