-1
{u'jobs': {u'_total': 301746, u'_count': 10, u'_start': 0, u'values': [{u'position':       {u'title': u'Director of Sales, New York '}, u'id': 7489651}, {u'position': {u'title': u'Senior Software Development Engineer'}, u'id': 7489610}, {u'position': {u'title': u'Senior Analyst, Marketing Analytics'}, u'id': 7489572}, {u'position': {u'title': u'Director,  Quantitative Analytics'}, u'id': 7489559}, {u'position': {u'title': u'Senior Quantitative Analyst'}, u'id': 7489542}, {u'position': {u'title': u'Director - Progam Lead and Project Manager - Collateral Management'}, u'id': 7489520}, {u'position': {u'title': u'Accounting and Finance Manager'}, u'id': 7489519}, {u'position': {u'title': u'Software Development Engineer - Test'}, u'id': 7489508}, {u'position': {u'title': u'Sr. Sales Executive - Technology'}, u'id': 7489462}, {u'position': {u'title': u'Recruitment Manager'}, u'id': 7489264}]}}

嗨,我对一般的脚本编写真的很陌生 - 数据库程序员。我正在尝试使用一个 python linkedIN api,它返回像上面那样格式化的数据。有人可以帮我解析这些数据吗?我想将数据存储到某种类型的 Python 数据结构中,然后最终将其写入数据库。

4

1 回答 1

3

LinkedIn API 的 Python 接口已经返回了一个 python 字典。

例如,您可以从您提供的数据中提取实际工作的列表:

from pprint import pprint

data = {u'jobs': {u'_total': 301746, u'_count': 10, u'_start': 0, u'values': [{u'position':       {u'title': u'Director of Sales, New York '}, u'id': 7489651}, {u'position': {u'title': u'Senior Software Development Engineer'}, u'id': 7489610}, {u'position': {u'title': u'Senior Analyst, Marketing Analytics'}, u'id': 7489572}, {u'position': {u'title': u'Director,  Quantitative Analytics'}, u'id': 7489559}, {u'position': {u'title': u'Senior Quantitative Analyst'}, u'id': 7489542}, {u'position': {u'title': u'Director - Progam Lead and Project Manager - Collateral Management'}, u'id': 7489520}, {u'position': {u'title': u'Accounting and Finance Manager'}, u'id': 7489519}, {u'position': {u'title': u'Software Development Engineer - Test'}, u'id': 7489508}, {u'position': {u'title': u'Sr. Sales Executive - Technology'}, u'id': 7489462}, {u'position': {u'title': u'Recruitment Manager'}, u'id': 7489264}]}}

pprint(data['jobs']['values'])

打印字典列表:

[{u'id': 7489651, u'position': {u'title': u'Director of Sales, New York '}},
 {u'id': 7489610,
  u'position': {u'title': u'Senior Software Development Engineer'}},
 {u'id': 7489572,
  u'position': {u'title': u'Senior Analyst, Marketing Analytics'}},
 {u'id': 7489559,
  u'position': {u'title': u'Director,  Quantitative Analytics'}},
 {u'id': 7489542, u'position': {u'title': u'Senior Quantitative Analyst'}},
 {u'id': 7489520,
  u'position': {u'title': u'Director - Progam Lead and Project Manager - Collateral Management'}},
 {u'id': 7489519, u'position': {u'title': u'Accounting and Finance Manager'}},
 {u'id': 7489508,
  u'position': {u'title': u'Software Development Engineer - Test'}},
 {u'id': 7489462,
  u'position': {u'title': u'Sr. Sales Executive - Technology'}},
 {u'id': 7489264, u'position': {u'title': u'Recruitment Manager'}}]
于 2013-09-26T00:47:47.180 回答