I'm trying to set up a for loop to pull in elected representatives' data for about 600,000 postal codes. 基本 URL 保持不变,唯一改变的部分是邮政编码。理想情况下,我想创建所有邮政编码的列表,然后使用 requests.get 提取列表中所有邮政编码的数据。我在下面想出了这个代码,但它只是为我的列表中的最后一个邮政编码提取数据。我不确定为什么会发生这种情况,我是一名 Python 初学者 - 所以任何帮助将不胜感激!#loop test postcodes = ['P0L1B0','P5A3P1', 'P5A3P2', 'P5A3P3']for i in range(len(postcodes)): rr = requests.get('https://represent.opennorth.ca/postcodes/{}'.format(postcodes[i]))data1=json.loads(rr.text)data1
添加回答
举报
0/150
提交
取消