JSearch

부분 유료
Verified
분류별 OpenWeb Ninja | 업데이트됨 8 дней назад | Jobs
인기

9.9 / 10

지연 시간

1,715ms

서비스 수준

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

아래에 의견을 추가하고 토론에 참여하세요.

새 댓글을 게시하려면 로그인 / 가입