I am getting the following error:
KeyError: 'sat'
in my Python script as below:
balls = {}
balls_count = 0
for entry_content in latest_results_soup.find_all('img',vspace='12'):
if balls_count < 5:
draw_day = 'sat'
else:
draw_day = 'wed'
balls[draw_day].append(int(entry_content['src'].rsplit('/', 1)[-1].split('.')[0]))
balls_count += 1
What i'm looking for is either a dict or list to parse further down which has a structure something like:
balls['sat'] = [5, 7, 20, 28, 30]
balls['wed'] = [1, 6, 9, 19, 20]
I feel like I am close (Python n00b, BTW) but clearly not close enough.
我认为您应该在设置值或附加值之前提供sat
和wed
键。
balls = {'sat': [], 'wed': []}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.