JSearch

FREEMIUM
От OpenWeb Ninja | Обновлено לפני 6 ימים | Jobs
Популярность

9.9 / 10

Задержка

1,637ms

Уровень обслуживания

100%

Health Check

100%

Назад ко всем обсуждениям

Trouble getting into further keys/items - Python

Rapid account: Sara M 2261
SaraM2261
לפני 3 חודשים

Hi!
I am having trouble getting the job_highlights > Qualifications info into my program. I am using Python. Have tried
for job in jobs response[‘data’]
jobQualifications = job[job_highlights’][‘Qualifications’]
print(jobQualifications)

result is key error
and also 

an inner for loop like 
for qualifications in job #further inner item than 'data'
	jobQualifications = qualifications['job_highlights']
	print(jobQualifications)
	
	result is key error
	
	Thank you for any help!
Rapid account: Letscrape 6 B R Ba 3 Qgu O 5
letscrape-6bRBa3QguO5 Commented לפני 3 חודשים

Hi there!

Thank you for your message.

Not every job has a job_highlights.Qualifications field, you can check if the key exist before accessing it. Here’s an example:

for job in jobs response[‘data’]:
if ‘job_highlights’ in job and ‘Qualifications’ in job[‘job_highlights’]:
print(job[‘job_highlights’][‘Qualifications’])

Does it work for you?

Thank you,
Adam @ OpenWeb Ninja

Присоединяйтесь к обсуждению – добавьте комментарий ниже:

Войдите / Зарегистрируйтесь, чтобы публиковать новые комментарии