在學習時箫攀,我們發(fā)現(xiàn)代碼
from pygal.i18n import COUNTRIES
for country_code in sorted(COUNTRIES.keys()):
print(country_code, COUNTRIES[country_code])
運行報錯
<img src="http://upload-images.jianshu.io/upload_images/6035053-70b7e46710249688.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="" />
原因是
COUNTRIES已經不在pygal.i18n模塊里了,而是在pygal.maps.world模塊里
用命令行 pip install pygal_maps_world
再修改一下代碼
from pygal.maps.world import COUNTRIES
for country_code in sorted(COUNTRIES.keys()):
print(country_code, COUNTRIES[country_code])
結果:
沒毛病
ok!
還沒完
在運行代碼
wm = pygal.Worldmap()
又出錯了旁理!
再修改一下下
wm = pygal.maps.world.World()
就行了
要注意的是 在現(xiàn)在的 pygal 里面 maps 原有的功能被劃分到了 maps.world里面