JSearch

FREEMIUM
Verified
Durch OpenWeb Ninja | Aktualisiert 8 days ago | Jobs
Popularität

9.9 / 10

Latenz

1,715ms

Service Level

100%

Health Check

100%

Zurück zu allen Diskussionen

Trouble getting into further keys/items - Python

Rapid account: Sara M 2261
SaraM2261
3 months ago

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 months ago

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

Nehmen Sie an der Diskussion teil - fügen Sie unten einen Kommentar hinzu:

Anmelden / Registrieren, um neue Kommentare zu veröffentlichen