0

我正在尝试渲染一个 json 文件,但它似乎不起作用。错误指出“在'/Users/tgiedraitis/PycharmProjects/GDP Visulization'中找不到''模块”。该值等于我从我正在处理的项目网站收到的文件名。如果您想查看数据和文件名的来源,请访问https://ehmatthes.github.io/pcc/solutions/chapter_16.html。然后在Solutions-Chapter 16下,点击“16-6 Gross Domestic Product”,然后点击“here”。最后,我单击“突出显示”并复制链接“// https://ehmatthes.github.io/pcc/resources/global_gdp.json”作为我的文件名值。我确保我的脚本路径和工作目录设置为正确的值,但错误仍然存​​在。有人可以帮我解决这个问题。谢谢。

import json
filename = "//https://ehmatthes.github.io/pcc/resources/global_gdp.json"

with open(filename) as f:
    gpd_data = json.load(f)

for gpd_dict in gpd_data:
    if gpd_dict ["Year"]  == "2014":
        country_name = gpd_dict["Country Name"]
        country_code = gpd_dict["Country Code"]
        print(country_name + ":" + country_code)
4

0 回答 0