JSearch

フリーミアム
Verified
よって OpenWeb Ninja | 更新済み vor 8 Tagen | Jobs
人気

9.9 / 10

レイテンシー

1,715ms

サービスレベル

100%

Health Check

100%

すべてのディスカッションに戻る

Trouble getting into further keys/items - Python

Rapid account: Sara M 2261
SaraM2261
vor 3 Monaten

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 vor 3 Monaten

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

ディスカッションに参加しましょう-以下にコメントを追加してください:

ログイン/サインアップして新しいコメントを投稿