Import JSON from Random_walk import Get_country_code to Pygal.maps.world import world from Pygal.style import rotatestyl E from Pygal.style import lightcolorizedstyle #from pygal.style import Rotatestyle as rs,lightcolorstyle as LCS filename = ' Population_data.json ' with open (filename) as F:pop_data = Json.load (f) cc_population={} to Pop_dict in Pop_data : If pop_dict[' year '] = = ': country_name = pop_dict[' country name '] population = int (float (pop_di ct[' Value ']) code = Get_country_code (country_name) if Code:cc_population[code]=population C c_1,cc_2,cc_3={},{},{} for Cc,pop in Cc_population.items (): If pop <10000000:cc_1[cc]=pop elif pop ; 1000000000:cc_2[cc]=pop Else:cc_3[cc]=pop print (len (cc_1), Len (cc_2), Len (cc_3)) #wm =world () #set The basic color #wm_style = Rotatestyle (' #336699 ') #brighten the Backgroudcolor #wm_style = Lightcolorizedstyle wm_styl E = Rotatestyle (' #336699', Base_style=lightcolorizedstyle) Wm=world (style=wm_style) Wm.title = "World population in 2010,by Country" #wm. Add (' 20 cc_population) #group The Data wm.add (' 0-10m ', cc_1) wm.add (' 10m-1bn ', cc_2) wm.add (' >1bn ', cc_3) wm.render_to_
File (' World_population.svg ')