Advertisement

Python数据分析中涉及的JSON文件

阅读量:

json格式:这里

绘制世界人口地图

The world population JSON file is essentially a lengthy list of Python objects. Each object is a dictionary containing four keys: country name, country code, year, and population value.

这里只关心每个国家2010年的人口数量。

打印出国别码以及相对应国家在2010年的人口数量

复制代码
 import json

    
  
    
 #将数据加载到一个列表中
    
 filename=r'C:\Users\LPH\Desktop\pythoncrashcourse配套资源\ehmatthes-pcc-6bfeca0\chapter_16\population_data.json'
    
 with open(filename) as f:
    
     pop_data=json.load(f)
    

全部评论 (0)

还没有任何评论哟~